-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (77 loc) · 2.52 KB
/
release.yml
File metadata and controls
82 lines (77 loc) · 2.52 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
name: release
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- run: npm install
- run: npm run typecheck
- run: npm test
- name: check tag matches package.json version
if: github.event_name == 'release'
run: |
pkg_version=$(node -p "require('./package.json').version")
tag_version="${GITHUB_REF_NAME#v}"
if [ "$pkg_version" != "$tag_version" ]; then
echo "::error::Release tag ($tag_version) does not match package.json version ($pkg_version)."
exit 1
fi
publish-npm:
needs: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- run: npm install
- name: check if version already on npm
id: pubcheck
run: |
name=$(node -p "require('./package.json').name")
version=$(node -p "require('./package.json').version")
if npm view "${name}@${version}" version --registry=https://registry.npmjs.org > /dev/null 2>&1; then
echo "already=true" >> "$GITHUB_OUTPUT"
echo "::notice::${name}@${version} already on npm — skipping publish."
else
echo "already=false" >> "$GITHUB_OUTPUT"
fi
- name: publish to npm
if: steps.pubcheck.outputs.already != 'true'
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-clawhub:
needs: verify
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: publish to ClawHub
env:
CLAWHUB_TOKEN: ${{ secrets.CLAWHUB_TOKEN }}
run: |
if [ -z "$CLAWHUB_TOKEN" ]; then
echo "::warning::CLAWHUB_TOKEN not set — skipping ClawHub publish."
exit 0
fi
npx -y clawhub login --token "$CLAWHUB_TOKEN" --no-browser
npx -y clawhub package publish . \
--source-repo "${GITHUB_REPOSITORY}" \
--source-ref "${GITHUB_REF_NAME}" \
--source-commit "${GITHUB_SHA}"