-
Notifications
You must be signed in to change notification settings - Fork 68
160 lines (141 loc) · 6.12 KB
/
Copy pathrelease.yml
File metadata and controls
160 lines (141 loc) · 6.12 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
151
152
153
154
155
156
157
158
159
160
# Publishes a release to GitHub Packages and Maven Central using JReleaser.
#
# HOW TO TRIGGER A RELEASE
# -------------------------
# 1. Update `edison_version` in build.gradle (on the target branch) to a non-SNAPSHOT version.
# 2. Update CHANGELOG.md with a "## <version>" entry on the same branch.
# 3. Commit and push to the target branch:
# git commit -am "chore: prepare release 4.1.1"
# git push
# 4. Trigger this workflow, specifying the version and branch:
# gh workflow run release.yml -f version=4.1.1 -f branch=main
# gh workflow run release.yml -f version=3.5.11 -f branch=3.5.x
# Or use the GitHub Actions UI: Actions → Release → Run workflow.
#
# After a successful release, bump build.gradle to the next SNAPSHOT version and commit.
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Release version (must match edison_version in build.gradle, without -SNAPSHOT)"
required: true
type: string
branch:
description: "Branch to release from"
required: true
type: choice
options:
- main
- 3.5.x
default: main
jobs:
release:
name: Release ${{ inputs.version }} from ${{ inputs.branch }}
runs-on: ubuntu-latest
permissions:
contents: write # needed to create GitHub releases and push the release tag
packages: write # needed to publish to GitHub Packages
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
fetch-depth: 0 # JReleaser needs full history to generate changelogs
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: gradle
- name: Enable pnpm via corepack
run: corepack enable
- name: Set up Node.js (for pnpm / JS tests)
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
cache-dependency-path: edison-jobs/pnpm-lock.yaml
- name: Validate version matches build.gradle
run: |
DECLARED=$(grep 'def edison_version' build.gradle | grep -o '"[^"]*"' | tr -d '"')
if [ "$DECLARED" != "${{ inputs.version }}" ]; then
echo "ERROR: Input version '${{ inputs.version }}' does not match build.gradle version '$DECLARED'."
echo "Update build.gradle first, commit, then re-run this workflow."
exit 1
fi
if [[ "$DECLARED" == *-SNAPSHOT ]]; then
echo "ERROR: build.gradle still contains a SNAPSHOT version: $DECLARED"
echo "Remove the -SNAPSHOT suffix before releasing."
exit 1
fi
echo "Version check passed: $DECLARED"
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build release notes from CHANGELOG.md and git history
run: |
mkdir -p build
VERSION="${{ inputs.version }}"
# 1. Extract the human-written section from CHANGELOG.md.
# Grabs everything between "## <version>" and the next "## " heading.
awk "/^## ${VERSION}$/{found=1; next} found && /^## /{exit} found{print}" CHANGELOG.md \
| sed '/^[[:space:]]*$/d' \
> build/release-notes.md
if [ ! -s build/release-notes.md ]; then
echo "ERROR: No changelog entry found for version '${VERSION}' in CHANGELOG.md."
echo "Add a '## ${VERSION}' section to CHANGELOG.md before releasing."
exit 1
fi
# 2. Append the git commit log since the previous release tag.
# Finds the most recent tag that is NOT the current version tag (which
# hasn't been created yet at this point), then lists commits up to HEAD.
PREV_TAG=$(git tag --sort=-version:refname \
| grep -v "^v\?${VERSION}$" \
| head -1)
if [ -n "$PREV_TAG" ]; then
echo "" >> build/release-notes.md
echo "## Commits since ${PREV_TAG}" >> build/release-notes.md
git log "${PREV_TAG}..HEAD" \
--pretty=format:"- %h %s" \
--no-merges \
>> build/release-notes.md
fi
echo "--- release-notes.md ---"
cat build/release-notes.md
- name: Validate JReleaser config
run: ./gradlew jreleaserConfig
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}
- name: Run tests
run: ./gradlew check
- name: Publish artifacts to staging
run: ./gradlew publish
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}
- name: Full release (GitHub + Maven Central)
run: ./gradlew jreleaserFullRelease
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}
- name: Upload JReleaser output on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: jreleaser-output
path: |
build/jreleaser/output.properties
build/jreleaser/trace.log