Repository navigation
76 lines (64 loc) · 2.62 KB
/
Copy pathrelease-cli.yml
File metadata and controls
76 lines (64 loc) · 2.62 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
name: Release CLI
on:
push:
tags:
- "cli-v*"
permissions:
contents: write
jobs:
release:
name: build + publish github release
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
cache: "pnpm"
- name: install
run: pnpm install --frozen-lockfile
- name: build cli
run: pnpm turbo run build --filter=@distrotv/cli
- name: verify build artifact
run: test -f packages/cli/dist/index.js
- name: stage release contents
env:
TAG_NAME: ${{ github.ref_name }}
run: |
mkdir -p .release-staging
cp -R packages/cli/dist .release-staging/
cp packages/cli/LICENSE .release-staging/
test -f packages/cli/README.md && cp packages/cli/README.md .release-staging/ || true
# Build a runtime package.json with only the native deps that can't
# be bundled (better-sqlite3 ships per-platform prebuilds). All
# pure-JS deps are bundled into dist/ by tsup's noExternal.
#
# version is derived from the release tag (cli-vX.Y.Z), NOT the
# committed pkg.version — the tag is the single source of truth so the
# installed CLI always reports the exact version users were nudged to.
# mirrors the prefix-strip in upgrade-check.ts fetchLatestVersion();
# falls back to pkg.version only if the ref name is somehow empty.
node -e "
const pkg = require('./packages/cli/package.json');
const tag = process.env.TAG_NAME || '';
const version = tag.replace(/^cli-v/, '').replace(/^v/, '') || pkg.version;
const runtime = {
name: pkg.name,
version,
type: pkg.type,
bin: pkg.bin,
dependencies: { 'better-sqlite3': pkg.dependencies['better-sqlite3'] },
};
require('fs').writeFileSync('.release-staging/package.json', JSON.stringify(runtime, null, 2));
"
- name: pack tarball
run: tar -czf distrotv-cli.tar.gz -C .release-staging .
- name: create github release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" distrotv-cli.tar.gz \
--title "CLI ${GITHUB_REF_NAME}" \
--notes "Built from $(git rev-parse --short HEAD)."