generated from LarsBodewig/Template
-
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
4704497
commit c45970f
Showing
2 changed files
with
73 additions
and
3 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 |
---|---|---|
|
@@ -8,9 +8,6 @@ | |
|
||
name: Maven Publish | ||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
|
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,73 @@ | ||
# Updates the maven version and checks in | ||
# --- | ||
# Add the following Github secrets from your Secret Manager | ||
# - PERSONAL_GITHUB_TOKEN | ||
|
||
name: Set version | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Set version' | ||
required: false | ||
type: string | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} | ||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'oracle' | ||
java-version: '17' | ||
- name: Evaluate old version | ||
if: ${{ inputs.version == '' }} | ||
run: | | ||
echo "oldVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_ENV" | ||
- name: Set next snapshot | ||
if: ${{ inputs.version == '' && !endsWith(env.oldVersion, '-SNAPSHOT') }} | ||
run: | | ||
mvn -B versions:set -DgenerateBackupPoms=false -DnextSnapshot=true | ||
echo "commitMsg=Next snapshot version" >> "$GITHUB_ENV" | ||
- name: Remove snapshot | ||
if: ${{ inputs.version == '' && endsWith(env.oldVersion, '-SNAPSHOT') }} | ||
run: | | ||
mvn -B versions:set -DgenerateBackupPoms=false -DremoveSnapshot=true | ||
echo "commitMsg=Remove snapshot version" >> "$GITHUB_ENV" | ||
- name: Set version | ||
if: ${{ inputs.version != '' }} | ||
run: | | ||
mvn -B versions:set -DgenerateBackupPoms=false -DnewVersion=${{ inputs.version }} | ||
echo "commitMsg=Set version to $inputs.version" >> "$GITHUB_ENV" | ||
- name: Evaluate new version | ||
if: ${{ inputs.version == '' && endsWith(env.oldVersion, '-SNAPSHOT') }} | ||
run: | | ||
echo "newVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_ENV" | ||
- name: Update version in README | ||
if: ${{ inputs.version == '' && endsWith(env.oldVersion, '-SNAPSHOT') }} | ||
uses: richardrigutins/replace-in-files@v2 | ||
with: | ||
files: 'README.md' | ||
search-text: '${{ env.oldVersion }}' | ||
replacement-text: '${{ env.newVersion }}' | ||
encoding: 'utf8' | ||
- name: Commit changes | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add . | ||
git commit -m "$commitMsg" | ||
- name: Set and push tag | ||
if: ${{ inputs.version == '' && endsWith(env.oldVersion, '-SNAPSHOT') }} | ||
run: | | ||
git tag -a "v$inputs.version" -m "v$inputs.version" -f | ||
git push origin v$inputs.version -f | ||
- name: Push commit | ||
run: | | ||
git push -f |