-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (202 loc) · 7.25 KB
/
Copy pathrelease.yml
File metadata and controls
230 lines (202 loc) · 7.25 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Release
on:
push:
tags:
- 'v*'
repository_dispatch:
types: [release-tag-created]
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., v0.1.0)'
required: true
type: string
permissions:
contents: write
packages: write
actions: write
jobs:
prepare:
name: Determine tag and verify CI
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
require_ci: ${{ steps.verify_ci.outputs.require_ci }}
steps:
- name: Determine tag to release
id: tag
env:
INPUT_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || '' }}
DISPATCH_TAG: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag || '' }}
REF_NAME: ${{ github.ref_name }}
run: |
if [ -n "${INPUT_TAG}" ]; then
TAG="${INPUT_TAG}"
elif [ -n "${DISPATCH_TAG}" ]; then
TAG="${DISPATCH_TAG}"
else
TAG="${REF_NAME}"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Releasing tag: $TAG"
- name: Ensure CI succeeded for tag commit
id: verify_ci
uses: actions/github-script@v8
env:
RELEASE_TAG: ${{ steps.tag.outputs.tag }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const tag = process.env.RELEASE_TAG;
if (!tag) {
core.setFailed('No release tag determined.');
return;
}
const { data: ref } = await github.rest.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `tags/${tag}`,
});
const sha = ref.object.sha;
core.info(`Tag ${tag} points to commit ${sha}`);
const { data } = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'ci.yml',
head_sha: sha,
per_page: 1,
});
const run = data.workflow_runs[0];
let requireCi = false;
if (!run) {
core.warning(`No CI workflow run found for commit ${sha}. Release workflow will rerun CI.`);
requireCi = true;
} else if (run.conclusion !== 'success') {
core.warning(`CI workflow run ${run.html_url} has conclusion ${run.conclusion}. Release workflow will rerun CI.`);
requireCi = true;
} else {
core.info(`CI workflow run ${run.html_url} succeeded at ${run.updated_at}.`);
}
core.setOutput('require_ci', requireCi ? 'true' : 'false');
ci:
name: Rerun CI if required
needs: prepare
if: needs.prepare.outputs.require_ci == 'true'
uses: ./.github/workflows/ci.yml
permissions:
contents: read
pull-requests: write
publish:
name: Publish to Maven Central
needs: [prepare, ci]
if: |
needs.prepare.outputs.require_ci != 'true' ||
(needs.prepare.outputs.require_ci == 'true' && needs.ci.result == 'success')
runs-on: ubuntu-latest
timeout-minutes: 60
env:
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
steps:
- name: Checkout tag
uses: actions/checkout@v6
with:
ref: refs/tags/${{ env.RELEASE_TAG }}
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Import and publish GPG key
id: gpg
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
run: |
set -euo pipefail
if [ -z "${PGP_SECRET:-}" ]; then
echo "PGP_SECRET is not configured"
exit 1
fi
echo "$PGP_SECRET" | base64 --decode | gpg --batch --import
KEY_FPR=$(gpg --list-secret-keys --with-colons | awk -F: '/^fpr:/ { print $10; exit }')
if [ -z "$KEY_FPR" ]; then
echo "Could not determine GPG key fingerprint"
exit 1
fi
echo "fingerprint=$KEY_FPR" >> "$GITHUB_OUTPUT"
echo "Using GPG fingerprint: $KEY_FPR"
KEYSERVER="hkps://keyserver.ubuntu.com"
if gpg --batch --keyserver "$KEYSERVER" --send-keys "$KEY_FPR"; then
echo "Uploaded public key to $KEYSERVER"
else
echo "::warning::Failed to upload key to $KEYSERVER. Ensure the fingerprint $KEY_FPR is published manually."
fi
- name: Get version
id: version
run: |
VERSION=$(sbt --batch --no-colors 'print version' | tail -1 | xargs)
echo "Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
TAG="${RELEASE_TAG}"
EXPECTED_VERSION="${TAG#v}"
if [ "$VERSION" != "$EXPECTED_VERSION" ]; then
echo "ERROR: Version mismatch!"
echo " Tag: $TAG"
echo " Expected version: $EXPECTED_VERSION"
echo " Actual version: $VERSION"
exit 1
fi
if [[ "$VERSION" =~ SNAPSHOT ]]; then
echo "ERROR: Tag release cannot have SNAPSHOT version!"
echo " Tag: $TAG"
echo " Version: $VERSION"
exit 1
fi
- name: Publish to Maven Central
run: sbt --batch --no-colors ci-release
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
CI_RELEASE: +publishSigned
CI_COMMIT_TAG: ${{ env.RELEASE_TAG }}
BUILD_SOURCEBRANCH: refs/tags/${{ env.RELEASE_TAG }}
GITHUB_REF: refs/tags/${{ env.RELEASE_TAG }}
- name: Package artifacts
run: sbt --batch --no-colors package
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.RELEASE_TAG }}
name: flowforge ${{ steps.version.outputs.version }}
body: |
## flowforge ${{ steps.version.outputs.version }}
Type-safe-first data engineering framework for compile-time contract enforcement.
### What's changed
- [Changelog](https://github.com/${{github.repository}}/blob/main/CHANGELOG.md)
### Installation
```scala
libraryDependencies += "com.flowforge" %% "flowforge-core" % "${{steps.version.outputs.version}}"
```
artifacts: "modules/**/target/scala-*/flowforge-*.jar"
draft: false
prerelease: false
makeLatest: true
allowUpdates: true
updateOnlyUnreleased: false
- name: Trigger Changelog update
uses: actions/github-script@v8
with:
script: |
await github.rest.repos.createDispatchEvent({
owner: context.repo.owner,
repo: context.repo.repo,
event_type: 'release-completed',
client_payload: {
tag: process.env.RELEASE_TAG
}
});