Release #21
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: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: 'Version Bump Type' | |
| required: true | |
| default: 'minor' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-x64 | |
| steps: | |
| - name: Get secrets | |
| uses: grafana/shared-workflows/actions/get-vault-secrets@39e279fe6459506c696fa5887a0a6ea012b30727 | |
| with: | |
| repo_secrets: | | |
| NEXUS_USERNAME=publishing:nexus_username | |
| NEXUS_PASSWORD=publishing:nexus_password | |
| NEXUS_GPG_KEY_ID=publishing:nexus_gpg_key_id | |
| NEXUS_GPG_PASSWORD=publishing:nexus_gpg_password | |
| NEXUS_GPG_SECRING_FILE_BASE64=publishing:nexus_gpg_secring_file | |
| GITHUB_APP_ID=pyroscope-development-app:app-id | |
| GITHUB_APP_PRIVATE_KEY=pyroscope-development-app:app-private-key | |
| - name: Generate GitHub token | |
| uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2 | |
| id: app-token | |
| with: | |
| app-id: ${{ env.GITHUB_APP_ID }} | |
| private-key: ${{ env.GITHUB_APP_PRIVATE_KEY }} | |
| - name: Checkout code | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| persist-credentials: true # push the tag later | |
| - name: Set up Java 11 | |
| uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| - name: Bump Version | |
| id: bump_version | |
| env: | |
| VERSION_BUMP: ${{ inputs.version_bump }} | |
| run: | | |
| current_version=$(grep 'pyroscope_version=' gradle.properties | cut -d'=' -f2) | |
| echo "Current version: $current_version" | |
| IFS='.' read -r major minor patch <<< "$current_version" | |
| case "$VERSION_BUMP" in | |
| "major") | |
| major=$((major + 1)) | |
| minor=0 | |
| patch=0 | |
| ;; | |
| "minor") | |
| minor=$((minor + 1)) | |
| patch=0 | |
| ;; | |
| "patch") | |
| patch=$((patch + 1)) | |
| ;; | |
| esac | |
| new_version="${major}.${minor}.${patch}" | |
| echo "New version: $new_version" | |
| sed -i "s/pyroscope_version=.*/pyroscope_version=$new_version/" gradle.properties | |
| echo "version=$new_version" >> $GITHUB_OUTPUT | |
| - name: Prepare GPG Keyring | |
| id: prepare_gpg_keyring | |
| run: | | |
| mkdir -p ${{ github.workspace }}/gpg | |
| echo "$NEXUS_GPG_SECRING_FILE_BASE64" | base64 -d > ${{ github.workspace }}/gpg/secring.gpg | |
| chmod 600 ${{ github.workspace }}/gpg/secring.gpg | |
| echo "keyring_path=${{ github.workspace }}/gpg/secring.gpg" >> $GITHUB_OUTPUT | |
| - name: Build and Publish | |
| env: | |
| NEXUS_GPG_SECRING_FILE: ${{ steps.prepare_gpg_keyring.outputs.keyring_path }} | |
| run: | | |
| make publish | |
| - name: Get GitHub App User ID | |
| id: get-user-id | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
| APP_SLUG: ${{ steps.app-token.outputs.app-slug }} | |
| run: | | |
| APP_BOT="${APP_SLUG}[bot]" | |
| echo "user-id=$(gh api "/users/${APP_BOT}" --jq .id)" >> "$GITHUB_OUTPUT" | |
| - name: Commit Version Bump | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
| APP_SLUG: ${{ steps.app-token.outputs.app-slug }} | |
| USER_ID: ${{ steps.get-user-id.outputs.user-id }} | |
| VERSION: ${{ steps.bump_version.outputs.version }} | |
| run: | | |
| APP_BOT="${APP_SLUG}[bot]" | |
| git config --global user.name "${APP_BOT}" | |
| git config --global user.email "${USER_ID}+${APP_BOT}@users.noreply.github.com" | |
| git add gradle.properties | |
| git commit -m "version ${VERSION}" | |
| git tag "v${VERSION}" | |
| git push --atomic origin "refs/heads/main" "refs/tags/v${VERSION}" | |
| - name: Create GitHub Release | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
| VERSION: ${{ steps.bump_version.outputs.version }} | |
| run: | | |
| gh release create "v${VERSION}" \ | |
| agent/build/libs/pyroscope.jar \ | |
| --title "Release v${VERSION}" \ | |
| --notes "Automated release" |