.github/workflows/version-updates.yml #2
This file contains hidden or 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
| on: | |
| workflow_run: | |
| workflows: | |
| - Release from GitHub Release | |
| types: | |
| - completed | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| create_pr: | |
| name: Create Pull Request | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Set up Git | |
| run: | | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --global user.name "github-actions[bot]" | |
| echo "BRANCH=version-updts" >> $GITHUB_ENV | |
| - name: Build PR | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git checkout -b $BRANCH | |
| # Get the current version | |
| RELEASED_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT$//') | |
| echo $RELEASED_VERSION | |
| # Increment the version | |
| ./mvnw build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT | |
| git add pom.xml | |
| # Get the next version | |
| NEXT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout | sed 's/-SNAPSHOT$//') | |
| echo $NEXT_VERSION | |
| # Replace version in README.md look for >, : (greater than, colon) followed by "2" period number period number (ex: 2.4.2) and replace it with the same leading char and current version | |
| sed -i -E 's/([\>\:]{1})2\.[0-9]\.[0-9]/\1'"$RELEASED_VERSION"'/g' README.md | |
| # Replace snapshot version in README.md look for "2" period number period number hyphen SNAPSHOT (ex: 2.4.2-SNAPSHOT) and replace it with the next version | |
| sed -i -E 's/2\.[0-9]\.[0-9]-SNAPSHOT/'"$NEXT_VERSION"-SNAPSHOT'/g' README.md | |
| git add README.md | |
| git commit -m "Released Datafaker $RELEASED_VERSION" -m "A release just completed, this PR updates the versions in pom.xml and README.md" --signoff | |
| git push --set-upstream origin $BRANCH --force | |
| gh pr create --fill |