Prepare release #5
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: Prepare release | |
| on: workflow_dispatch | |
| jobs: | |
| prepare_release: | |
| name: Prepare release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Verify prerequisites | |
| run: | | |
| if [[ $GITHUB_REF_NAME != main ]]; then | |
| echo This workflow should only be run against main | |
| exit 1 | |
| fi | |
| - uses: actions/create-github-app-token@v2 | |
| id: app-token | |
| with: | |
| app-id: ${{ vars.APP_ID }} | |
| private-key: ${{ secrets.PRIVATE_KEY }} | |
| - name: Get GitHub App User ID and set up git config | |
| id: get-user-id | |
| run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| - run: | | |
| git config --global user.name '${{ steps.app-token.outputs.app-slug }}[bot]' | |
| git config --global user.email '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com>' | |
| - uses: actions/checkout@v6 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Setting variables | |
| id: variables | |
| run: | | |
| version=$(cat gradle.properties | grep -Po "(?<=version=)\d+\.\d+\.\d+") | |
| echo "The version is $version" | |
| { | |
| echo "version=$version" | |
| echo "release_branch=release/$version" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Creating release branch | |
| env: | |
| RELEASE_BRANCH: ${{ steps.variables.outputs.release_branch }} | |
| run: | | |
| git checkout -b $RELEASE_BRANCH | |
| git push --set-upstream origin $RELEASE_BRANCH | |
| - name: Updating the CHANGELOG.md file | |
| run: ./gradlew changelogUpdate | |
| - name: Creating release branch PR | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| VERSION: ${{ steps.variables.outputs.version }} | |
| RELEASE_BRANCH: ${{ steps.variables.outputs.release_branch }} | |
| run: | | |
| message="Prepare release $VERSION" | |
| branch="pre-release/$VERSION" | |
| git checkout -b $branch | |
| git commit -a -m "$message" | |
| git push --set-upstream origin $branch | |
| gh pr create --title "[$RELEASE_BRANCH] $message" \ | |
| --body "$message." \ | |
| --base $RELEASE_BRANCH |