-
Notifications
You must be signed in to change notification settings - Fork 10
61 lines (51 loc) · 1.54 KB
/
publish.yml
File metadata and controls
61 lines (51 loc) · 1.54 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
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
npm:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: pnpm/action-setup@v2
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- name: Install
run: pnpm install --frozen-lockfile
- name: Verify tag matches package.json version
run: node scripts/ci/ensure-tag-matches-package.mjs
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Check if version already published
run: |
VERSION="$(node -e "console.log(JSON.parse(require('fs').readFileSync('package.json','utf8')).version)")"
if npm view "codebase-context@${VERSION}" version >/dev/null 2>&1; then
echo "Version ${VERSION} already exists on npm; skipping publish."
echo "SKIP_PUBLISH=true" >> "$GITHUB_ENV"
else
echo "Version ${VERSION} not found on npm; will publish."
fi
- name: Quality gates
if: env.SKIP_PUBLISH != 'true'
run: |
pnpm lint
pnpm format:check
pnpm type-check
pnpm test
pnpm build
- name: Publish
if: env.SKIP_PUBLISH != 'true'
run: pnpm publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}