generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 17
292 lines (265 loc) · 9.55 KB
/
release.yaml
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version of web5 to release and publish to TBD Artifactory and Maven Central. For example "1.0.0" or "1.3.7-beta-2". Required. Must not end in "-SNAPSHOT".'
required: true
# TODO: Remove
pull_request:
branches:
- main
env:
WEB5_SDK_LOG_LEVEL: debug
jobs:
run-ci:
# This will run CI and also publish the Kotlin release to the TBD Artifactory repo manager
name: Run CI
uses: TBD54566975/web5-rs/.github/workflows/ci.yml@main
secrets: inherit
with:
version: ${{ github.event.inputs.version }}
git-tag:
runs-on: ubuntu-latest
needs: run-ci
outputs:
RELEASE_TAG: ${{ steps.set-version-and-tag.outputs.RELEASE_TAG }}
RELEASE_VERSION: ${{ steps.set-version-and-tag.outputs.RELEASE_VERSION }}
name: Create Git Tag
steps:
- id: checkout
uses: actions/checkout@v4
with:
submodules: true
token: ${{ secrets.GITHUB_TOKEN }}
# Used in writing commits in the release process
- id: set-git-config
name: Set Git Config
run: |
git config user.name "tbd-releases"
git config user.email "[email protected]"
# Cache Maven repo
- id: cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- id: set-version-and-tag
name: Set version of Kotlin and commit
run: |
# cd into the Kotlin project
cd bound/kt/
# Get the required provided version
version=${{ github.event.inputs.version }}
# Precondition check; do not allow this to proceed if a version ending in "-SNAPSHOT" was specified
if [[ $version =~ -SNAPSHOT$ ]]; then
echo "Error: The version for release must not end with \"-SNAPSHOT\": $version"
exit 1
fi
# Get the existing version from the POM and set it to the nextVersion, keeping the POM effectively versionless
nextVersion=$(grep -oPm1 "(?<=<version>)[^<]+" pom.xml)
if [[ -z $nextVersion ]]; then
echo "Error: Could not find a version in the pom.xml"
exit 1
fi
echo "Version to be released: $version"
echo "Setting next development version back to original in pom.xml: $nextVersion"
# Set newly resolved version in POM config
mvn \
versions:set \
--batch-mode \
-DnewVersion=$version
# Commit
git add -Av
git commit -m "[TBD Release Manager 🚀] Setting version to: $version"
tagName=v$version
git tag -a $tagName -m "Tag version: $tagName" # We tag with a prefix of "v"
# Make the version and tag name available to subsequent jobs as an output param
echo "RELEASE_TAG=$tagName" >> "$GITHUB_OUTPUT"
echo "RELEASE_VERSION=$version" >> "$GITHUB_OUTPUT"
cat $GITHUB_OUTPUT
# Set the next development version and commit and push
mvn \
versions:set \
--batch-mode \
-DnewVersion=$nextVersion
git add -Av
git commit -m "[TBD Release Manager 🚀] Setting next development version after $version to: $nextVersion"
git push origin main
git push origin $tagName
kotlin-release-to-tbd-artifactory-and-maven-central:
name: Release Kotlin to Maven Central
needs: git-tag
runs-on: ubuntu-latest
steps:
# Check out the tag we created above
- uses: actions/checkout@v4
with:
submodules: true
ref: ${{ needs.git-tag.outputs.RELEASE_TAG }} # Check out the tag we created above
# Set up JDK
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: "11"
# Cache Maven repo
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Package up the native binaries
#TODO Centralize this block as we re-use it via copy/paste right now
- name: Download MacOS aarch64 Native Library
uses: actions/[email protected]
with:
name: aarch64-apple-darwin-dylib
path: bound/kt/src/main/resources/
- name: Download MacOS x86_64 Native Library
uses: actions/[email protected]
with:
name: x86_64-apple-darwin-dylib
path: bound/kt/src/main/resources/
- name: Download Linux x86_64 GNU Native Library
uses: actions/[email protected]
with:
name: x86_64-unknown-linux-gnu-so
path: bound/kt/src/main/resources/
- name: Download Linux x86_64 MUSL Native Library
uses: actions/[email protected]
with:
name: x86_64-unknown-linux-musl-so
path: bound/kt/src/main/resources/
- name: Download Windows x86_64 MSVC Native Library
uses: actions/[email protected]
with:
name: x86_64-pc-windows-msvc-dll
path: bound/kt/src/main/resources/
- name: Deploy Release Version of Kotlin Project to Maven Central
run: |
# cd into the Kotlin project
cd bound/kt/
# Publish to Sonatype
# Precondition check: Only attempt to publish artifact if we have credentials
if [ -n "${{ secrets.SONATYPE_PASSWORD }}" ]; then
# Maven deploy lifecycle will build, run tests, verify, sign, and deploy
mvn deploy --batch-mode \
--settings .maven_settings.xml \
-P ossrh,sign-artifacts
else
echo "Error: No credentials"
exit 1
fi
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SIGN_KEY_PASS: ${{ secrets.GPG_SECRET_PASSPHRASE }}
SIGN_KEY: ${{ secrets.GPG_SECRET_KEY }}
kotlin-docs:
permissions:
contents: read
pages: write
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "adopt"
java-version: "11"
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn dokka:dokka
working-directory: bound/kt
- run: mkdir _site && mv bound/kt/target/dokka _site/kt
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
#name: Build release artifacts
#
#on:
# release:
# types: [created]
#
#jobs:
# build_cli_aarch64-apple-darwin:
# runs-on: macos-latest
# name: aarch64-apple-darwin
# steps:
# - uses: actions/checkout@v2
# - name: Install Rust
# run: rustup toolchain install stable
# - name: cargo build
# run: |
# cargo build --target aarch64-apple-darwin --release --package web5_cli
# cp -v target/aarch64-apple-darwin/release/web5_cli web5_cli-aarch64-apple-darwin
# - name: upload release asset
# uses: AButler/[email protected]
# with:
# files: web5_cli-aarch64-apple-darwin
# repo-token: ${{ secrets.GITHUB_TOKEN }}
#
# build_cli_x86_64_apple_darwin:
# runs-on: macos-12
# name: x86_64-apple-darwin
# steps:
# - uses: actions/checkout@v2
# - name: Install Rust
# run: rustup toolchain install stable
# - name: cargo build
# run: |
# cargo build --target x86_64-apple-darwin --release --package web5_cli
# cp -v target/x86_64-apple-darwin/release/web5_cli web5_cli-x86_64-apple-darwin
# - name: upload release asset
# uses: AButler/[email protected]
# with:
# files: web5_cli-x86_64-apple-darwin
# repo-token: ${{ secrets.GITHUB_TOKEN }}
#
# build_cli_x86_64_unknown_linux_gnu:
# runs-on: ubuntu-latest
# name: x86_64-unknown-linux-gnu
# steps:
# - uses: actions/checkout@v2
# - name: cargo build
# run: |
# cargo build --target x86_64-unknown-linux-gnu --release --package web5_cli
# cp -v target/x86_64-unknown-linux-gnu/release/web5_cli web5_cli-x86_64-unknown-linux-gnu
# - name: upload release asset
# uses: AButler/[email protected]
# with:
# files: web5_cli-x86_64-unknown-linux-gnu
# repo-token: ${{ secrets.GITHUB_TOKEN }}
#
# build_cli_x86_64_unknown_linux_musl:
# runs-on: ubuntu-latest
# name: x86_64-unknown-linux-musl
# steps:
# - uses: actions/checkout@v2
# - name: Run Build Script
# run: |
# pushd crates/web5_cli/build/x86_64_unknown_linux_musl
# ./build
# popd
# cp target/x86_64-unknown-linux-musl/release/web5_cli web5_cli-x86_64-unknown-linux-musl
# - name: upload release asset
# uses: AButler/[email protected]
# with:
# files: web5_cli-x86_64-unknown-linux-musl
# repo-token: ${{ secrets.GITHUB_TOKEN }}
#