-
Notifications
You must be signed in to change notification settings - Fork 9
61 lines (52 loc) · 1.71 KB
/
publish-npm-on-release.yml
File metadata and controls
61 lines (52 loc) · 1.71 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
# Publishes to npm when a GitHub release is created (or on manual run for a given tag).
# Use when release-please didn't run publish (e.g. manual release or "chore: release" merge).
name: Publish to npm on release
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish (e.g. v2.2.0)'
required: true
default: 'v2.2.0'
permissions:
contents: read
id-token: write
jobs:
publish:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.event.release.tag_name }}
- uses: pnpm/action-setup@v2
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- name: Check if version already published
id: check
run: |
VERSION="$(node -e "console.log(JSON.parse(require('fs').readFileSync('package.json','utf8')).version)")"
if npm view "codebase-context@${VERSION}" version 2>/dev/null; then
echo "already_published=true" >> "$GITHUB_OUTPUT"
else
echo "already_published=false" >> "$GITHUB_OUTPUT"
fi
- name: Quality gates
if: steps.check.outputs.already_published != 'true'
run: |
pnpm lint
pnpm format:check
pnpm type-check
pnpm build
pnpm test
- name: Publish to npm with provenance
if: steps.check.outputs.already_published != 'true'
run: pnpm publish --access public --no-git-checks --provenance