Skip to content

Commit

Permalink
Update build-and-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlo committed Feb 4, 2024
1 parent b6309e1 commit 81915d6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
52 changes: 37 additions & 15 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,18 @@ name: Release to Maven Central

on:
release:
types: [ published ]
types: [ released ]

permissions:
contents: write



jobs:
build-for-release:
release:
runs-on: ubuntu-latest

outputs:
new-version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
ref: master
- name: Setup git config
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Set up JDK 19
uses: actions/setup-java@v4
with:
Expand All @@ -33,14 +25,44 @@ jobs:
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN

- if: github.event.release
name: Update version in pom.xml (Release only)
run: mvn -B versions:set -DnewVersion=${{ github.event.release.tag_name }} -DgenerateBackupPoms=false
- name: Get next version
uses: reecetech/[email protected]
id: version
with:
release_branch: master
scheme: semver
increment: patch

- name: Update version in pom.xml
run: mvn -B versions:set -DnewVersion=${{ steps.version.outputs.version }} -DgenerateBackupPoms=false

- name: Verify and deploy
run: mvn -B deploy --file pom.xml
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
after-release:
runs-on: ubuntu-latest
needs: release

steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.DEV_BRANCH }}

- name: Setup git config
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Setup next version
run: mvn -B versions:set -DnewVersion=${{ needs.release.outputs.new-version }}-SNAPSHOT -DgenerateBackupPoms=false

- name: Commit and push
run: |
git add -A
git commit -m "Prepare pom for new iteration"
git push
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>io.github.codeblo</groupId>
<artifactId>rollbacker</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.3-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
Expand Down

0 comments on commit 81915d6

Please sign in to comment.