Repository navigation
64 lines (60 loc) · 1.97 KB
/
Copy pathnodejs-publish.yml
File metadata and controls
64 lines (60 loc) · 1.97 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
name: Node.js Package
on:
push:
tags: ['*']
workflow_dispatch:
inputs:
release_tag:
description: Previously reviewed release tag
required: true
type: choice
options: ['v2.4.3']
permissions:
contents: read
concurrency:
group: publish-${{ inputs.release_tag || github.ref }}
cancel-in-progress: false
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.release_tag || github.ref }}
persist-credentials: false
- name: Verify release identity
env:
RELEASE_TAG: ${{ inputs.release_tag || github.ref_name }}
MANUAL_RELEASE: ${{ github.event_name == 'workflow_dispatch' }}
run: |
node <<'NODE'
const assert = require('node:assert/strict');
const { execFileSync } = require('node:child_process');
const pkg = require('./package.json');
const head = execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
assert.equal(pkg.name, 'schema-typed');
assert.equal(process.env.RELEASE_TAG, 'v' + pkg.version);
if (process.env.MANUAL_RELEASE === 'true') {
assert.equal(process.env.RELEASE_TAG, 'v2.4.3');
assert.equal(head, '09c22ccba99903048c0cbde6e678c85e959c8e2e');
}
console.log({ tag: process.env.RELEASE_TAG, head, version: pkg.version });
NODE
- uses: actions/setup-node@v4
with:
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Set up npm for trusted publishing
run: npm install --global npm@11.21.0
- name: Record publication runtime
run: |
node --version
npm --version
- name: Install dependencies
run: npm ci
- name: Publish with OIDC
run: npm publish --access public