-
Notifications
You must be signed in to change notification settings - Fork 1
150 lines (125 loc) · 5.46 KB
/
Copy pathrelease-junit.yml
File metadata and controls
150 lines (125 loc) · 5.46 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Release tabletest-junit
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g. 1.0.1)'
required: true
type: string
dry-run:
description: 'Build and validate without deploying or pushing'
required: false
type: boolean
default: false
env:
VERSION: ${{ inputs.version }}
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v6
with:
java-version: '25'
distribution: 'temurin'
server-id: central
server-username: MAVEN_CENTRAL_USERNAME
server-password: MAVEN_CENTRAL_PASSWORD
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Cache Maven repository
uses: actions/cache@v6
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-release-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-release-
- name: Validate preconditions
run: |
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "::error::Version '$VERSION' does not match semver pattern (e.g. 1.0.1)"
exit 1
fi
UNRELEASED=$(sed -n '/^## \[Unreleased\]/,/^## \[/p' CHANGELOG.md | sed '1d;$d')
if [ -z "$UNRELEASED" ]; then
echo "::error::CHANGELOG.md has no content under [Unreleased]"
exit 1
fi
if git tag -l "tabletest-junit-$VERSION" | grep -q .; then
echo "::error::Tag tabletest-junit-$VERSION already exists"
exit 1
fi
PARSER_DEP=$(grep -oP '(?<=<version.tabletest-parser>)[^<]+' tabletest-junit/pom.xml)
if [[ "$PARSER_DEP" == *-SNAPSHOT ]]; then
echo "::error::tabletest-junit depends on parser $PARSER_DEP — release parser first or update the dependency"
exit 1
fi
echo "All preconditions passed"
- name: Set release version
run: mvn -f tabletest-junit/pom.xml versions:set -DnewVersion="$VERSION" -DgenerateBackupPoms=false -q
- name: Stamp changelog
run: |
TODAY=$(date +%Y-%m-%d)
sed -i "s|^## \[Unreleased\]|## [Unreleased]\n\n## [$VERSION] - $TODAY|" CHANGELOG.md
- name: Update README.md
run: |
sed -i '/<artifactId>tabletest-junit<\/artifactId>/{n;s|<version>[0-9]\+\.[0-9]\+\.[0-9]\+</version>|<version>'"$VERSION"'</version>|}' README.md
sed -i 's|org.tabletest:tabletest-junit:[0-9]\+\.[0-9]\+\.[0-9]\+|org.tabletest:tabletest-junit:'"$VERSION"'|' README.md
- name: Commit release
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "release: tabletest-junit $VERSION"
- name: Show release commit
if: inputs.dry-run
run: git show --stat HEAD && echo "---" && git show HEAD
- name: Deploy
if: ${{ !inputs.dry-run }}
run: mvn -f tabletest-junit/pom.xml clean deploy -Prelease -DskipTests --no-transfer-progress
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Create git tag
run: git tag "tabletest-junit-$VERSION"
- name: Set next development version
run: |
NEXT_PATCH=$(echo "$VERSION" | awk -F. '{print $1"."$2"."$3+1}')
NEXT_SNAPSHOT="${NEXT_PATCH}-SNAPSHOT"
mvn -f tabletest-junit/pom.xml versions:set -DnewVersion="$NEXT_SNAPSHOT" -DgenerateBackupPoms=false -q
# Update test-compatibility.sh default
sed -i "s|TABLETEST_VERSION=\"[^\"]*\"|TABLETEST_VERSION=\"$NEXT_SNAPSHOT\"|" test-compatibility.sh
# Update compatibility test build files
find compatibility-tests -name 'pom.xml' -exec \
sed -i "s|<tabletest.version>[^<]*</tabletest.version>|<tabletest.version>$NEXT_SNAPSHOT</tabletest.version>|" {} +
find compatibility-tests -name 'build.gradle' -exec \
sed -i "s|?: '[0-9]\+\.[0-9]\+\.[0-9]\+-SNAPSHOT'|?: '$NEXT_SNAPSHOT'|" {} +
find compatibility-tests -name 'build.gradle.kts' -exec \
sed -i "s|?: \"[0-9]\+\.[0-9]\+\.[0-9]\+-SNAPSHOT\"|?: \"$NEXT_SNAPSHOT\"|" {} +
- name: Commit next development version
run: |
NEXT_PATCH=$(echo "$VERSION" | awk -F. '{print $1"."$2"."$3+1}')
NEXT_SNAPSHOT="${NEXT_PATCH}-SNAPSHOT"
git add -A
git commit -m "chore: set tabletest-junit development version $NEXT_SNAPSHOT"
- name: Show next development version commit
if: inputs.dry-run
run: git show --stat HEAD && echo "---" && git show HEAD
- name: Push commits and tags
if: ${{ !inputs.dry-run }}
run: git push origin main --tags
- name: Create GitHub release
if: ${{ !inputs.dry-run }}
run: |
BODY=$(sed -n "/^## \[$VERSION\]/,/^## \[/{/^## \[/!p}" CHANGELOG.md)
gh release create "tabletest-junit-$VERSION" \
--title "TableTest JUnit $VERSION" \
--notes "$BODY"
env:
GH_TOKEN: ${{ github.token }}