-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (58 loc) · 2.03 KB
/
Copy pathpublish.yml
File metadata and controls
61 lines (58 loc) · 2.03 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
name: Publish npm package
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
publish:
runs-on: macos-latest
environment: npm
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: https://registry.npmjs.org
package-manager-cache: false
- run: npm ci
- name: Upgrade npm for OIDC trusted publishing
run: npm install --global npm@^11.5.1
- name: Install required test tooling
run: |
if ! command -v rg >/dev/null; then
brew install ripgrep
fi
- run: npm run build:agent
- run: npm test
env:
FORCE_COLOR: "1"
- run: npm run typecheck
- name: Verify the Git tag matches package version
if: github.event_name == 'push'
run: |
VERSION=$(node -p "require('./packages/cli/package.json').version")
test "$GITHUB_REF_NAME" = "v$VERSION"
- run: mkdir -p release-artifacts && npm pack ./packages/cli --pack-destination release-artifacts
- name: Publish to npm with provenance
run: |
VERSION=$(node -p "require('./packages/cli/package.json').version")
if npm view "@tree201/do-code@$VERSION" version >/dev/null 2>&1; then
echo "@tree201/do-code@$VERSION is already published"
else
npm publish ./packages/cli --access public
fi
- name: Create GitHub release
if: github.event_name == 'push'
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" release-artifacts/*.tgz --clobber
elif [[ "$GITHUB_REF_NAME" == *-* ]]; then
gh release create "$GITHUB_REF_NAME" release-artifacts/*.tgz --generate-notes --prerelease
else
gh release create "$GITHUB_REF_NAME" release-artifacts/*.tgz --generate-notes
fi