-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (114 loc) · 4.35 KB
/
Copy pathrelease.yml
File metadata and controls
135 lines (114 loc) · 4.35 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: Manual Release to Maven Central
on:
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency: release
jobs:
release:
runs-on: ubuntu-latest
outputs:
next_snapshot: ${{ steps.compute.outputs.next_snapshot }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Import GPG key
run: |
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
echo "no-tty" >> ~/.gnupg/gpg.conf
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --yes --pinentry-mode loopback --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import
- name: Get current version
id: version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "current=$VERSION" >> $GITHUB_OUTPUT
- name: Compute release + next snapshot
id: compute
run: |
BASE=${{ steps.version.outputs.current }}
BASE=${BASE%-SNAPSHOT}
X=$(echo $BASE | cut -d. -f1)
Y=$(echo $BASE | cut -d. -f2)
NEW_Y=$((Y + 1))
RELEASE="$X.$NEW_Y"
NEXT_SNAPSHOT="$X.$NEW_Y-SNAPSHOT"
echo "release=$RELEASE" >> $GITHUB_OUTPUT
echo "next_snapshot=$NEXT_SNAPSHOT" >> $GITHUB_OUTPUT
# 1️⃣ Set release version everywhere
- name: Set release version
run: |
mvn versions:set \
-DnewVersion=${{ steps.compute.outputs.release }} \
-DprocessAllModules=true \
-DgenerateBackupPoms=false
# 2️⃣ Deploy selected modules
- name: Deploy selected modules
run: |
mvn -pl functional-definitions/annotation-definitions,functional-definitions/functional-compiler -am clean deploy \
-Dmaven.test.skip=true \
-Dgpg.pinentryMode=loopback \
-Dgpg.passphrase="${GPG_PASSPHRASE}"
env:
MAVEN_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
# 3️⃣ Commit release + tag
- name: Commit release and tag
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git commit -am "Release ${{ steps.compute.outputs.release }}"
git tag v${{ steps.compute.outputs.release }}
git push origin v${{ steps.compute.outputs.release }}
# 4️⃣ Set next snapshot
- name: Set next snapshot
run: |
mvn versions:set \
-DnewVersion=${{ steps.compute.outputs.next_snapshot }} \
-DprocessAllModules=true \
-DgenerateBackupPoms=false
# 5️⃣ Set version in CHANGELOG
- name: Update CHANGELOG for release
run: |
VERSION=${{ steps.compute.outputs.release }}
DATE=$(date +%Y-%m-%d)
awk -v version="$VERSION" -v date="$DATE" '
BEGIN { unreleased=0 }
/^## \[Unreleased\]/ {
print "## [Unreleased]"
print ""
print "## [" version "] - " date
unreleased=1
next
}
unreleased==1 { print; next }
{ print }
' CHANGELOG.md > CHANGELOG.tmp
mv CHANGELOG.tmp CHANGELOG.md
# 6️⃣ Commit snapshot on new branch
- name: Create snapshot branch
run: |
git checkout -b bump-${{ steps.compute.outputs.next_snapshot }}
git commit -am "Bump version to ${{ steps.compute.outputs.next_snapshot }}"
git push origin HEAD
# 7️⃣ Create PR instead of pushing to master
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
branch: bump-${{ steps.compute.outputs.next_snapshot }}
title: "Bump version to ${{ steps.compute.outputs.next_snapshot }}"
body: "Automatic snapshot bump after Maven Central release."