-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from flyway/auto-version
Create Auto-Versioning Github Action
- Loading branch information
Showing
1 changed file
with
50 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,50 @@ | ||
name: Auto-Version new contributions to Flyway Community DB Support | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
jobs: | ||
auto-version: | ||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Flyway Community DB Support | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
fetch-tags: true | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
cache: 'maven' | ||
- name: Check for new module | ||
id: check_module | ||
run: | | ||
git fetch --tags -q | ||
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) | ||
if git diff --diff-filter=ADR --name-only $LATEST_TAG..HEAD -- '*pom.xml' | grep -q pom.xml; then | ||
echo "NEW_MODULE=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "NEW_MODULE=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Update version | ||
id: update_version | ||
run: | | ||
if ${{ steps.check_module.outputs.NEW_MODULE }}; then | ||
NEW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | awk -F'[.-]' '{print $1"."$2+1".0"}') | ||
else | ||
NEW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | awk -F'[.-]' '{print $1"."$2"."$3+1}') | ||
fi | ||
mvn versions:set -DnewVersion=$NEW_VERSION | ||
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT | ||
- name: Commit and tag | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
author_name: rg-buildmonkey | ||
author_email: github-buildmonkey@red-gate.com | ||
message: 'Bump Flyway Community DB Support to ${{ steps.update_version.outputs.NEW_VERSION }}' | ||
tag: '${{ steps.update_version.outputs.NEW_VERSION }}' |