-
Notifications
You must be signed in to change notification settings - Fork 4
74 lines (62 loc) · 2.37 KB
/
Copy pathpublish.yml
File metadata and controls
74 lines (62 loc) · 2.37 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
name: Publish Package to npmjs
on:
release:
types: [published]
permissions:
id-token: write # Required for OIDC
contents: read
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
- name: Prepare publish version
env:
PUBLISH_VERSION: ${{ github.event.release.tag_name }}
run: bun scripts/prepublish.ts
- name: Verify package version matches release tag
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
EXPECTED_VERSION="${RELEASE_TAG#v}"
ACTUAL_VERSION="$(node -p "require('./package.json').version")"
echo "release tag: ${RELEASE_TAG} -> expected ${EXPECTED_VERSION}, package.json has ${ACTUAL_VERSION}"
test "${ACTUAL_VERSION}" = "${EXPECTED_VERSION}"
- name: Build package
run: bun run build
# Node 18 must only be on PATH for the verification below, not during
# the build: typescript >= 7 ships an extensionless ESM bin/tsc that
# Node 18.17 cannot load (ERR_UNKNOWN_FILE_EXTENSION).
- name: Set up Node.js 18 for runtime verification
uses: actions/setup-node@v6
with:
node-version: '18.17.0'
- name: Verify built CLI with Node.js 18
run: |
node --version
node lib/bin.js -v
node lib/bin-cresc.js -v
# the programmatic entry points must also load on the minimum
# supported Node, not only the CLI banner
node -e "const m = require('./lib/exports.js'); if (!m) process.exit(1)"
node -e "const d = require('./lib/diff.js'); if (!d.diffCommands) process.exit(1)"
- name: Set up Node.js for npm publishing
uses: actions/setup-node@v6
with:
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'
- name: Verify publishable package contents
run: npm pack --dry-run --ignore-scripts
- name: Publish to npm
shell: bash
run: |
if [[ "${{ github.event.release.tag_name }}" == *"beta"* ]]; then
npm publish --ignore-scripts --provenance --access public --tag beta
else
npm publish --ignore-scripts --provenance --access public
fi