-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3f0d13
commit af9ca87
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Release Workflow | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# 1. Checkout repository | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# 2. Set up Java environment | ||
- name: Set up Java 21 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '21' | ||
|
||
# 3. Extract version from the release tag | ||
- name: Extract version from tag | ||
id: extract_version | ||
run: | | ||
VERSION="${GITHUB_REF#refs/tags/v}" | ||
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION" | ||
echo "RELEASE_VERSION=${MAJOR}.${MINOR}.${PATCH}-1.21.3" >> $GITHUB_ENV | ||
echo "NEXT_SNAPSHOT_VERSION=${MAJOR}.${MINOR}.$((PATCH + 1))-1.21.3-SNAPSHOT" >> $GITHUB_ENV | ||
# 4. Update pom.xml to release version | ||
- name: Update version in pom.xml for release | ||
run: | | ||
mvn versions:set -DnewVersion="${{ env.RELEASE_VERSION }}" | ||
mvn versions:commit | ||
# 5. Commit the updated pom.xml for release version | ||
- name: Commit updated pom.xml | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git commit -am "Set version to ${{ env.RELEASE_VERSION }}" | ||
# 6. Create a new tag for the release version | ||
- name: Create tag for release | ||
run: | | ||
git tag "v${{ env.RELEASE_VERSION }}" | ||
git push origin "v${{ env.RELEASE_VERSION }}" | ||
# 7. Build the project | ||
- name: Build with Maven | ||
run: | | ||
mvn install | ||
mvn package | ||
# 8. Upload JAR files to GitHub Release | ||
- name: Upload JAR files to GitHub Release | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: target/*.jar | ||
asset_name: "${{ github.event.release.tag_name }}-jar-files.zip" | ||
asset_content_type: application/zip | ||
|
||
# 9. Update pom.xml to next SNAPSHOT version | ||
- name: Update version in pom.xml to next SNAPSHOT | ||
run: | | ||
mvn versions:set -DnewVersion="${{ env.NEXT_SNAPSHOT_VERSION }}" | ||
mvn versions:commit | ||
# 10. Commit updated pom.xml for next SNAPSHOT version | ||
- name: Commit next SNAPSHOT version | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git commit -am "Set version to ${{ env.NEXT_SNAPSHOT_VERSION }}" | ||
# 11. Push changes back to the repository | ||
- name: Push changes | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |