Skip to content

Commit 2260f7c

Browse files
committed
Add release automation
1 parent 9a98e33 commit 2260f7c

File tree

4 files changed

+231
-0
lines changed

4 files changed

+231
-0
lines changed

.github/workflows/release.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Release new version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
push:
7+
description: 'Push artifacts to Central and commits to the repository'
8+
required: true
9+
default: true
10+
type: 'boolean'
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
packages: write
18+
env:
19+
STAGED_REPOSITORY: target/checkout/target/staging-deploy
20+
21+
steps:
22+
- name: Check if release is running from master
23+
run: |
24+
if [ "${GITHUB_REF}" != "refs/heads/master" ]; then
25+
echo "Release is only allowed from master branch"
26+
exit 1
27+
fi
28+
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Install java
35+
uses: actions/setup-java@v4
36+
with:
37+
java-version: '17'
38+
distribution: 'temurin'
39+
gpg-private-key: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
40+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
41+
cache: 'maven'
42+
43+
- name: Configure git
44+
run: |
45+
git config user.name "Airlift Release"
46+
git config user.email "[email protected]"
47+
48+
- name: Lock branch before release
49+
uses: github/lock@v2
50+
id: release-lock
51+
with:
52+
mode: 'lock'
53+
54+
- name: Run mvn release:prepare
55+
env:
56+
MAVEN_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
57+
run: |
58+
./mvnw -B release:prepare -Poss-release,oss-stage
59+
60+
- name: Determine release version
61+
run: |
62+
export VERSION=$(grep 'scm.tag=' release.properties | cut -d'=' -f2)
63+
echo "VERSION=${VERSION}" >> $GITHUB_ENV
64+
echo "Releasing version: ${VERSION}"
65+
66+
- name: Run mvn release:perform to local staging
67+
env:
68+
MAVEN_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
69+
run: |
70+
./mvnw -B release:perform -Poss-release,oss-stage
71+
72+
- name: Display git status and history
73+
run: |
74+
git status
75+
git log --oneline -n 2
76+
77+
- name: List locally staged artifacts
78+
run: |
79+
find ${{ env.STAGED_REPOSITORY }} -type f
80+
81+
- name: Run JReleaser
82+
uses: jreleaser/release-action@v2
83+
env:
84+
JRELEASER_PROJECT_VERSION: ${{ env.VERSION }}
85+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
JRELEASER_GPG_PUBLIC_KEY: ${{ vars.JRELEASER_GPG_PUBLIC_KEY }}
87+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }}
88+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }}
89+
JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME }}
90+
JRELEASER_NEXUS2_MAVEN_CENTRAL_TOKEN: ${{ secrets.JRELEASER_NEXUS2_MAVEN_CENTRAL_TOKEN }}
91+
JRELEASER_NEXUS2_END_STAGE: ${{ inputs.push && 'RELEASE' || 'CLOSE' }}
92+
JRELEASER_SKIP_RELEASE: ${{ inputs.push && 'false' || 'true' }}
93+
with:
94+
setup-java: false
95+
96+
- name: Push git changes
97+
if: ${{ inputs.push }}
98+
run: |
99+
git status
100+
git push origin master
101+
102+
- name: Unlock branch after a release
103+
uses: github/lock@v2
104+
id: release-unlock
105+
with:
106+
mode: 'unlock'
107+
108+
- name: Upload JReleaser logs
109+
if: always()
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: jreleaser-logs
113+
path: |
114+
out/jreleaser/trace.log
115+
out/jreleaser/output.properties

airbase/pom.xml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,27 @@
16501650
</build>
16511651
</profile>
16521652

1653+
<!-- this is not activated by default so we don't break existing releases -->
1654+
<profile>
1655+
<id>oss-stage</id>
1656+
<properties>
1657+
<!-- Stage files to the local directory, JReleaser will push them to OSSRH -->
1658+
<altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository>
1659+
</properties>
1660+
<build>
1661+
<plugins>
1662+
<plugin>
1663+
<groupId>org.apache.maven.plugins</groupId>
1664+
<artifactId>maven-release-plugin</artifactId>
1665+
<configuration>
1666+
<!-- we will push commits and tags manually in the workflow -->
1667+
<pushChanges>false</pushChanges>
1668+
</configuration>
1669+
</plugin>
1670+
</plugins>
1671+
</build>
1672+
</profile>
1673+
16531674
<profile>
16541675
<id>ci</id>
16551676
<build>

jreleaser.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Hooks that will run on the CI to generate the summary of the steps
2+
hooks:
3+
condition: '"{{ Env.CI }}" == true'
4+
script:
5+
before:
6+
- filter:
7+
includes: ['session']
8+
run: |
9+
echo "### {{command}}" >> $GITHUB_STEP_SUMMARY
10+
echo "| Step | Outcome |" >> $GITHUB_STEP_SUMMARY
11+
echo "| ---- | ------- |" >> $GITHUB_STEP_SUMMARY
12+
success:
13+
- filter:
14+
excludes: ['session']
15+
run: 'echo "| {{event.name}} | :white_check_mark: |" >> $GITHUB_STEP_SUMMARY'
16+
- filter:
17+
includes: ['session']
18+
run: echo "" >> $GITHUB_STEP_SUMMARY
19+
failure:
20+
- filter:
21+
excludes: ['session']
22+
run: 'echo "| {{event.name}} | :x: |" >> $GITHUB_STEP_SUMMARY'
23+
- filter:
24+
includes: ['session']
25+
run: |
26+
echo "" >> $GITHUB_STEP_SUMMARY
27+
echo "### Failure" >> $GITHUB_STEP_SUMMARY
28+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
29+
echo "{{event.stacktrace}}\`\`\`" >> $GITHUB_STEP_SUMMARY
30+
echo "" >> $GITHUB_STEP_SUMMARY
31+
32+
# Project configuration
33+
project:
34+
name: airbase
35+
description: Base POM for Airlift
36+
license: Apache-2
37+
java:
38+
groupId: io.airlift
39+
multiProject: true
40+
41+
# Ordered as defined in the https://jreleaser.org/guide/latest/concepts/workflow.html#_full_release
42+
signing:
43+
active: ALWAYS
44+
armored: true
45+
46+
# Deploy to OSSRH
47+
deploy:
48+
maven:
49+
pomchecker:
50+
failOnWarning: false # We don't want to fail the build on warnings
51+
failOnError: false # We don't want to fail the build on errors
52+
nexus2:
53+
maven-central:
54+
active: ALWAYS
55+
url: https://oss.sonatype.org/service/local
56+
snapshotUrl: https://oss.sonatype.org/content/repositories/snapshots/
57+
javadocJar: false # Not every module has javadoc (packaging)
58+
closeRepository: true
59+
releaseRepository: true
60+
stagingRepositories:
61+
- target/checkout/target/staging-deploy
62+
63+
# Release to Github
64+
release:
65+
github:
66+
owner: airlift
67+
overwrite: true # if tag already exists, overwrite it
68+
skipTag: true # created by the release plugin
69+
branch: master
70+
uploadAssets: NEVER
71+
tagName: '{{projectVersion}}'
72+
files: false
73+
draft: false
74+
releaseNotes:
75+
enabled: true
76+
configurationFile: .github/release.yml

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,24 @@
146146
</plugins>
147147
</build>
148148
</profile>
149+
<profile>
150+
<id>oss-stage</id>
151+
<properties>
152+
<!-- Stage files to the local directory, JReleaser will push them to OSSRH -->
153+
<altDeploymentRepository>local::file:./target/staging-deploy</altDeploymentRepository>
154+
</properties>
155+
<build>
156+
<plugins>
157+
<plugin>
158+
<groupId>org.apache.maven.plugins</groupId>
159+
<artifactId>maven-release-plugin</artifactId>
160+
<configuration>
161+
<!-- we will push commits and tags manually in the workflow -->
162+
<pushChanges>false</pushChanges>
163+
</configuration>
164+
</plugin>
165+
</plugins>
166+
</build>
167+
</profile>
149168
</profiles>
150169
</project>

0 commit comments

Comments
 (0)