Skip to content

Commit 57da31e

Browse files
committed
Add release automation
1 parent edd13df commit 57da31e

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Release new version
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
packages: write
12+
13+
steps:
14+
- name: Check if release is running from master
15+
run: |
16+
if [ "${GITHUB_REF}" != "refs/heads/master" ]; then
17+
echo "Release is only allowed from master branch"
18+
exit 1
19+
fi
20+
21+
- name: Checkout code
22+
uses: actions/checkout@v6
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Install java
27+
uses: actions/setup-java@v5
28+
with:
29+
java-version: 25
30+
distribution: 'temurin'
31+
gpg-private-key: ${{ secrets.RELEASE_GPG_SECRET_KEY }}
32+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
33+
cache: 'maven'
34+
35+
- name: Configure git
36+
run: |
37+
git config user.name "Trino Release"
38+
git config user.email "trino-bot@trino.io"
39+
40+
- name: Lock branch before release
41+
uses: github/lock@v3
42+
id: release-lock
43+
with:
44+
mode: lock
45+
46+
- name: Prepare build image
47+
run: ./build-image.sh
48+
49+
- name: Run ./mvnw release:prepare
50+
env:
51+
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASE_GPG_PASSPHRASE }}
52+
run: |
53+
./mvnw -B release:prepare -Poss-release
54+
55+
- name: Determine release version
56+
run: |
57+
export VERSION=$(grep 'scm.tag=' release.properties | cut -d'=' -f2)
58+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
59+
echo "Releasing version: ${VERSION}"
60+
61+
- name: Run ./mvnw release:perform to local staging
62+
env:
63+
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASE_GPG_PASSPHRASE }}
64+
run: |
65+
./mvnw -B release:perform -Poss-release
66+
67+
- name: Display git status and history
68+
run: |
69+
git status
70+
git log --oneline -n 2
71+
72+
- name: Run njord:validate
73+
env:
74+
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASE_GPG_PASSPHRASE }}
75+
MAVENCENTRAL_USERNAME: ${{ vars.RELEASE_MAVEN_CENTRAL_USERNAME }}
76+
MAVENCENTRAL_PASSWORD: ${{ secrets.RELEASE_MAVEN_CENTRAL_TOKEN }}
77+
run: |
78+
./mvnw njord:list
79+
./mvnw njord:status
80+
./mvnw njord:validate
81+
82+
- name: Run njord:publish
83+
env:
84+
MAVEN_GPG_PASSPHRASE: ${{ secrets.RELEASE_GPG_PASSPHRASE }}
85+
MAVENCENTRAL_USERNAME: ${{ vars.RELEASE_MAVEN_CENTRAL_USERNAME }}
86+
MAVENCENTRAL_PASSWORD: ${{ secrets.RELEASE_MAVEN_CENTRAL_TOKEN }}
87+
run:
88+
./mvnw njord:publish -Poss-release
89+
90+
- name: Push git changes
91+
run: |
92+
git status
93+
git describe
94+
git push origin master
95+
git push origin --tags
96+
97+
- name: Unlock branch after a release
98+
uses: github/lock@v3
99+
id: release-unlock
100+
with:
101+
mode: unlock
102+
103+
- name: Create release notes
104+
env:
105+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
106+
run: |
107+
gh release create "${VERSION}" \
108+
--repo="${GITHUB_REPOSITORY}" \
109+
--title="${GITHUB_REPOSITORY#*/} ${VERSION}" \
110+
--generate-notes

0 commit comments

Comments
 (0)