CI - Release #12
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
| name: "CI - Release" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version' | |
| required: true | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| VERSION: ${{ steps.vars.outputs.VERSION }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: 21 | |
| cache: 'maven' | |
| server-id: central | |
| server-username: MAVEN_USERNAME # Sonatype "snowdrop-team" usertoken: username | |
| server-password: MAVEN_PASSWORD # Sonatype "snowdrop-team" usertoken: password | |
| gpg-private-key: ${{ secrets.GPG_SECRET_KEY }} # snowdrop-core@redhat.com gpg private key | |
| gpg-passphrase: MAVEN_GPG_PASSPHRASE # snowdrop-core@redhat.com gpg passphrase | |
| - name: Configure git user and email | |
| run: | | |
| git config --global user.email "action@github.com" | |
| git config --global user.name "Github Action" | |
| - name: Create a release branch | |
| run: | | |
| VERSION=${{ github.event.inputs.version }} | |
| git checkout -b release-$VERSION | |
| - name: Set the maven version to the release version | |
| run: | | |
| VERSION=${{ github.event.inputs.version }} | |
| mvn -ntp -B versions:set versions:commit -DprocessAllModules=true -DprocessParent -DnewVersion=$VERSION | |
| - name: Update jbang-catalog.json | |
| run: | | |
| VERSION=${{ github.event.inputs.version }} | |
| RELEASE_URL="https://github.com/${{ github.repository }}/releases/download/$VERSION/migration-cli-$VERSION-runner.jar" | |
| echo "Updating catalog with new URL: ${RELEASE_URL}" | |
| jq --arg url "$RELEASE_URL" '.aliases.mtool["script-ref"] = $url' jbang-catalog.json > temp.json && mv temp.json jbang-catalog.json | |
| - name: Update the cookbook rules using the snowdrop openrewrite recipes jar | |
| run: | | |
| VERSION=${{ github.event.inputs.version }} | |
| echo "Bump the yaml rules containing the snowdrop openrewrite recipes jar too" | |
| find cookbook/rules -name "*.yaml" -exec sed -i "s|dev.snowdrop.mtool:openrewrite-recipes:[0-9.]*\(-SNAPSHOT\)\{0,1\}|dev.snowdrop.mtool:openrewrite-recipes:$PROJECT_VERSION|g" {} + | |
| - name: Commit the changes | |
| run: | | |
| VERSION=${{ github.event.inputs.version }} | |
| git add . | |
| git commit -m "release: ${VERSION} and jbang catalog update" | |
| - name: Build the uber-jar and run jreleaser | |
| run: | | |
| mvn -ntp -B clean install -Dquarkus.package.type=uber-jar | |
| mvn -ntp -B jreleaser:full-release -N | |
| env: | |
| JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Deploy the maven GAV on central | |
| run: | | |
| mvn -B deploy -Prelease -DskipTests | |
| env: | |
| MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
| MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
| MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Push branch and Create Pull Request | |
| run: | | |
| VERSION=${{ github.event.inputs.version }} | |
| git push origin release-$VERSION | |
| gh pr create \ | |
| --title "Release $VERSION" \ | |
| --body "Automated release PR" \ | |
| --base main \ | |
| --head release-$VERSION | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: JReleaser output | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: jreleaser-release | |
| path: | | |
| target/jreleaser/trace.log | |
| target/jreleaser/output.properties |