Skip to content

Bump async profiler to v4.3 (#258) #3

Bump async profiler to v4.3 (#258)

Bump async profiler to v4.3 (#258) #3

name: Publish Release
on:
push:
branches: [main]
paths:
- 'gradle.properties'
permissions:
contents: write
packages: write
id-token: write
jobs:
publish:
runs-on: ubuntu-x64
steps:
- name: Check if release commit
id: check
run: |
COMMIT_MSG=$(cat "$GITHUB_EVENT_PATH" | jq -r '.head_commit.message')
# Match "version X.Y.Z" (merge/rebase) or "Release vX.Y.Z" (squash merge)
if [[ "$COMMIT_MSG" =~ ^version\ ([0-9]+\.[0-9]+\.[0-9]+) ]]; then
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
echo "is_release=true" >> $GITHUB_OUTPUT
elif [[ "$COMMIT_MSG" =~ ^Release\ v([0-9]+\.[0-9]+\.[0-9]+) ]]; then
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
echo "is_release=true" >> $GITHUB_OUTPUT
else
echo "is_release=false" >> $GITHUB_OUTPUT
fi
- name: Get secrets
if: steps.check.outputs.is_release == 'true'
uses: grafana/shared-workflows/actions/get-vault-secrets@ac5193564bb463032623a9a0ba23716f866f309c
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
if: steps.check.outputs.is_release == 'true'
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2
id: app-token
with:
app-id: ${{ env.GITHUB_APP_ID }}
private-key: ${{ env.GITHUB_APP_PRIVATE_KEY }}
- name: Checkout code
if: steps.check.outputs.is_release == 'true'
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
token: ${{ steps.app-token.outputs.token }}
persist-credentials: true
- name: Set up Java 11
if: steps.check.outputs.is_release == 'true'
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: '11'
distribution: 'temurin'
- name: Prepare GPG Keyring
if: steps.check.outputs.is_release == 'true'
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
if: steps.check.outputs.is_release == 'true'
env:
NEXUS_GPG_SECRING_FILE: ${{ steps.prepare_gpg_keyring.outputs.keyring_path }}
run: |
make publish
- name: Get GitHub App User ID
if: steps.check.outputs.is_release == 'true'
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: Create Tag
if: steps.check.outputs.is_release == 'true'
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.check.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 tag "v${VERSION}"
git push origin "v${VERSION}"
- name: Create GitHub Release
if: steps.check.outputs.is_release == 'true'
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
VERSION: ${{ steps.check.outputs.version }}
run: |
gh release create "v${VERSION}" \
agent/build/libs/pyroscope.jar \
--title "Release v${VERSION}" \
--notes "Automated release"