-
Notifications
You must be signed in to change notification settings - Fork 32
103 lines (90 loc) · 3.24 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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"