Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add release github actions #55

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release

run-name: Create Release

on:
push:
tags:
- "v*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Extract tag version
run: echo "tag=$(echo '${{ github.ref_name }}' | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')" >> $GITHUB_OUTPUT
id: extract_tag_version
- name: Build project
run: ./gradlew assemble
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only do assemble...
Don't we need release plugin replace SNAHOP version to empty string?

Copy link
Contributor

@taeyeon-Kim taeyeon-Kim Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assemble doesn't run a test. How about replacing it with build task?

Copy link
Contributor Author

@sohyun-ku sohyun-ku Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junoyoon
This action is just create release & tag when pushed release/* branch.
So if we want to replace SNAPSHOT version to empty string, we'll have to do it by self.

I was some confusion because the operation of the gradle-release plugin was different from the current release step.
It seems to have a similar operation to what you said this #52 (comment), so I'll check again

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taeyeon-Kim
If we create release branch from main branch, I think assemble is enough becuz main branch already build in this actions.

name: Main Build
on:
pull_request:
branches: [ main ]
jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Test with Gradle
run: ./gradlew clean build
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
report_individual_runs: true
check_name: "Scavenger Test Results"
junit_files: "**/build/test-results/**/*.xml"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junoyoon

We can use gradle-release plugin if merging release branch to main is ok.
Using gradle-release commits tag version and new version at working branch.
We want to create tag at release branch, we can use pushReleaseVersionBranch option. (reference)
But using pushReleaseVersionBranch will checkout to the release branch and merge from the working branch.
If we don't use pushReleaseVersionBarnch option, just commit working branch.(in our case maybe working branch is main)

If we decide to use gradle-release plugin, I'd like to proceed release step as follows.

1. Checkout release branch and commit release version by developer.
  - It can be replaced with the gradle release plugin, but for some reason it is difficult to control it with the github action.
2. Using github actions on push event at release branch, trigger gradle-release plugin. 
  - This step is creating TAG.
3. Using github actions on tag event, create Release.

cc. @naver/scavenger-dev

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will review this weekend? ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@junoyoon
#55 (comment) is outdated.
plz refer #55 (comment)
When release, we only have to Pull Request develop to main branch.
Other tasks are done as Github Actions.

- name: Create Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.RELEASE_ACTIONS_TOKEN }}
files: |
./scavenger-agent-java/build/libs/scavenger-agent-java-${{ steps.extract_tag_version.outputs.tag }}.jar
./scavenger-old-agent-java/build/libs/scavenger-old-agent-java-${{ steps.extract_tag_version.outputs.tag }}.jar
./scavenger-api/build/libs/scavenger-api-boot-${{ steps.extract_tag_version.outputs.tag }}.jar
./scavenger-collector/build/libs/scavenger-collector-boot-${{ steps.extract_tag_version.outputs.tag }}.jar
generate_release_notes: true
30 changes: 30 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Tag

run-name: Create Tag

on:
pull_request:
types:
- closed
branches:
- main

jobs:
if_merged:
if: github.event.pull_request.merged == true && startsWith( github.event.pull_request.title, 'release' )
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.RELEASE_ACTIONS_TOKEN }}
- name: Extract version
run: echo "version=$(echo '${{ github.event.pull_request.title }}' | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')" >> $GITHUB_OUTPUT
id: extract_version
- name: Set git config
run: |
git config user.name sohyun-ku
git config user.email [email protected]
git branch release/${{ steps.extract_version.outputs.version }}
- name: Create tag
run: ./gradlew :release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ steps.extract_version.outputs.version }}
18 changes: 17 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
idea
id("net.researchgate.release") version "3.0.2"
}

allprojects {
group = "com.navercorp.scavenger"
version = "1.0.4"

repositories {
mavenCentral()
Expand All @@ -20,6 +20,22 @@ allprojects {
}
}

release {
val releaseVersion = if (hasProperty("release.releaseVersion")) {
property("release.releaseVersion")
} else {
version
}

pushReleaseVersionBranch.set("release/${ releaseVersion }")
tagTemplate.set("v${ releaseVersion }")
preTagCommitMessage.set("Release ")
newVersionCommitMessage.set("Update next development version after Release")
with(git) {
requireBranch.set("main")
}
}

subprojects {
tasks.withType<Test> {
useJUnitPlatform()
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version=1.0.5-SNAPSHOT
kotlin.code.style=official
restAssuredVersion=4.3.3
springDataJdbcPlusVersion=2.2.3
Expand Down