Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the release pipeline to a GitHub action #171

Merged
merged 10 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
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-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Java 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'

- name: Bump Version
id: bump_version
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 "${{ inputs.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: Get secrets
uses: grafana/shared-workflows/actions/get-vault-secrets@main
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

- 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
run: |
export NEXUS_GPG_SECRING_FILE=${{ steps.prepare_gpg_keyring.outputs.keyring_path }}
make publish

- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add gradle.properties
git commit -m "version ${{ steps.bump_version.outputs.version }}"
git tag "v${{ steps.bump_version.outputs.version }}"
git push --atomic origin "refs/heads/main" "refs/tags/v${{ steps.bump_version.outputs.version }}"

- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "v${{ steps.bump_version.outputs.version }}" \
agent/build/libs/pyroscope.jar \
--title "Release v${{ steps.bump_version.outputs.version }}" \
--notes "Automated release"
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ publish:
-Psigning.secretKeyRingFile="$(NEXUS_GPG_SECRING_FILE)" \
-Psigning.password="$(NEXUS_GPG_PASSWORD)" \
-Psigning.keyId="$(NEXUS_GPG_KEY_ID)"
@echo "Now you go https://s01.oss.sonatype.org, close the temporarly created staging repository and release it"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was technically incorrect, we use "closeAndReleaseSonatypeStagingRepository" which afaik does that for us

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think this is a leftover

@echo "https://central.sonatype.org/publish/release/#locate-and-examine-your-staging-repository"

.PHONY: test
Expand Down
Loading