Repository navigation
79 lines (66 loc) · 2.1 KB
/
Copy pathcli-release.yml
File metadata and controls
79 lines (66 loc) · 2.1 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
name: Release CLI
on:
push:
branches:
- main
paths:
- 'cli/**'
- 'packages/backend-sdk/**'
- '.changeset/**'
- '.github/workflows/cli-release.yml'
defaults:
run:
working-directory: ./cli
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
package_json_file: package.json
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
registry-url: 'https://registry.npmjs.org'
- name: Install
run: pnpm install --frozen-lockfile --filter "@cryptly/cli..."
- name: Test
run: pnpm test
- name: Build
run: pnpm build
- name: Detect pending changesets
id: detect
run: |
pending=$(find ../.changeset -name "*.md" ! -name "README.md" 2>/dev/null | wc -l | tr -d ' ')
echo "pending=$pending" >> "$GITHUB_OUTPUT"
echo "Found $pending pending changeset(s)."
# Bumps cli/package.json, regenerates CHANGELOG.md, deletes the consumed
# changesets, then commits & pushes back to main. Pushes made by the
# default GITHUB_TOKEN don't trigger workflow runs, so this can't loop.
- name: Version + commit
if: steps.detect.outputs.pending != '0'
run: |
set -e
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
pnpm changeset version
git add -A
git commit -m "chore(cli): release"
git push origin "HEAD:${GITHUB_REF_NAME}"
# Idempotent: if the current version is already on npm, this is a no-op.
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: pnpm changeset publish