Repository navigation
289 lines (254 loc) · 9.27 KB
/
Copy pathrelease.yml
File metadata and controls
289 lines (254 loc) · 9.27 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
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
name: Release
on:
push:
tags:
- "v*"
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
environment: GoogleOAuth2
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-14
- target: x86_64-apple-darwin
os: macos-14
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04-arm
steps:
- uses: actions/checkout@v5
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.93.0"
- name: Install Rust target
run: rustup target add ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: ${{ matrix.target }}
- name: Extract version
id: version
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }} --bin ok
env:
OAK_GOOGLE_CLIENT_ID: ${{ secrets.OAK_GOOGLE_CLIENT_ID }}
OAK_GOOGLE_CLIENT_SECRET: ${{ secrets.OAK_GOOGLE_CLIENT_SECRET }}
- name: Package artifact
env:
VERSION: ${{ steps.version.outputs.version }}
TARGET: ${{ matrix.target }}
run: |
PACKAGE_NAME="ok-v${VERSION}-${TARGET}"
PACKAGE_DIR="dist/${PACKAGE_NAME}"
mkdir -p "${PACKAGE_DIR}"
cp "target/${TARGET}/release/ok" "${PACKAGE_DIR}/ok"
for doc in README.md README-ZH.md INSTALL.md INSTALL-ZH.md SECURITY.md LICENSE; do
[ -f "$doc" ] && cp "$doc" "${PACKAGE_DIR}/"
done
tar -C dist -czf "dist/${PACKAGE_NAME}.tar.gz" "${PACKAGE_NAME}"
- uses: actions/upload-artifact@v5
with:
name: artifact-${{ matrix.target }}
path: dist/*.tar.gz
retention-days: 7
checksums:
name: Generate checksums
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v5
with:
pattern: artifact-*
path: dist
merge-multiple: true
- name: Generate checksums
run: |
cd dist
shasum -a 256 *.tar.gz > checksums.txt
cat checksums.txt
- uses: actions/upload-artifact@v5
with:
name: checksums
path: dist/checksums.txt
retention-days: 7
release:
name: GitHub Release
runs-on: ubuntu-latest
needs: [build, checksums]
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v5
with:
pattern: artifact-*
path: dist
merge-multiple: true
- uses: actions/download-artifact@v5
with:
name: checksums
path: dist
- name: Extract version
id: version
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build release notes
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
# Extract changelog entry for this version
if grep -q "^## ${VERSION}" CHANGELOG.md; then
sed -n "/^## ${VERSION}/,/^## /{ /^## ${VERSION}/p; /^## [0-9]/!p; }" CHANGELOG.md \
| head -n -1 > release_notes.md
else
{
echo "## ok v${VERSION}"
echo ""
echo "See [CHANGELOG.md](https://github.com/OpenKeyring/oak-keyring/blob/master/CHANGELOG.md) for details."
} > release_notes.md
fi
# Append preview caveat + install instructions + checksums
{
echo ""
echo "---"
echo ""
echo "## ⚠️ Preview Release Notice"
echo ""
echo "This is a **preview release** of ok. Preview releases may change local vault, sync, import, and export formats before a stable release line exists."
echo ""
echo "### macOS Gatekeeper Warning"
echo ""
echo "The macOS artifacts are **unsigned and not notarized**. On first run you may see:"
echo ""
echo '> "ok" cannot be opened because the developer cannot be verified.'
echo ""
echo "From Terminal:"
echo ""
echo '```bash'
echo "xattr -d com.apple.quarantine ok"
echo '```'
echo ""
echo "### Linux Requirements"
echo ""
echo "Linux builds target glibc 2.35 or newer (Ubuntu 22.04+, Debian 12+, Fedora, RHEL/Rocky/Alma 9+, Arch, openSUSE). They do not cover Alpine (musl) or older glibc releases such as Debian 11."
echo ""
echo "ok locks secrets in memory with mlock. Most distributions default to a low RLIMIT_MEMLOCK (often 64 KiB), which can cause vault creation or unlock to fail. Raise it before running ok, for example: ulimit -l unlimited, a /etc/security/limits.conf entry, a systemd LimitMEMLOCK=infinity directive, or setcap cap_ipc_lock=ep. See INSTALL.md for details."
echo ""
echo "### Install"
echo ""
echo "Available targets: aarch64-apple-darwin, x86_64-apple-darwin, x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu."
echo ""
echo '```bash'
echo "tar -xzf ok-v${VERSION}-<target>.tar.gz"
echo "sudo mv ok-v${VERSION}-<target>/ok /usr/local/bin/"
echo '```'
echo ""
echo "Or install via npm:"
echo ""
echo '```bash'
echo "npm install -g @openkeyring/ok"
echo '```'
echo ""
echo "## Checksums"
echo ""
cat dist/checksums.txt
} >> release_notes.md
- name: Determine pre-release
id: prerelease
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
if [[ "$VERSION" =~ -(preview|alpha|beta|rc)\. ]]; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: ok v${{ steps.version.outputs.version }}
body_path: release_notes.md
draft: false
prerelease: ${{ steps.prerelease.outputs.prerelease }}
files: |
dist/*.tar.gz
dist/checksums.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
name: Publish npm
runs-on: ubuntu-latest
needs: build
environment: NPM
steps:
- uses: actions/checkout@v5
- uses: actions/download-artifact@v5
with:
pattern: artifact-*
path: dist
merge-multiple: true
- uses: actions/setup-node@v5
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
- name: Extract version
id: version
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Sync npm package versions
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
npm --prefix npm/ok-darwin-arm64 version "$VERSION" --no-git-tag-version
npm --prefix npm/ok-darwin-x64 version "$VERSION" --no-git-tag-version
npm --prefix npm/ok-linux-x64 version "$VERSION" --no-git-tag-version
npm --prefix npm/ok-linux-arm64 version "$VERSION" --no-git-tag-version
npm --prefix npm/ok version "$VERSION" --no-git-tag-version
# Update optionalDependencies to match
node -e "
const fs = require('fs');
const pkg = JSON.parse(fs.readFileSync('npm/ok/package.json', 'utf8'));
for (const dep of Object.keys(pkg.optionalDependencies)) {
pkg.optionalDependencies[dep] = process.env.VERSION;
}
fs.writeFileSync('npm/ok/package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Stage binaries
run: bash npm/stage-binaries.sh
- name: Verify packages (dry-run)
run: |
npm pack ./npm/ok-darwin-arm64 --dry-run
npm pack ./npm/ok-darwin-x64 --dry-run
npm pack ./npm/ok-linux-x64 --dry-run
npm pack ./npm/ok-linux-arm64 --dry-run
npm pack ./npm/ok --dry-run
- name: Publish @openkeyring/ok-darwin-arm64
run: npm publish ./npm/ok-darwin-arm64
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish @openkeyring/ok-darwin-x64
run: npm publish ./npm/ok-darwin-x64
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish @openkeyring/ok-linux-x64
run: npm publish ./npm/ok-linux-x64
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish @openkeyring/ok-linux-arm64
run: npm publish ./npm/ok-linux-arm64
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish @openkeyring/ok
run: npm publish ./npm/ok
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}