-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (63 loc) · 1.98 KB
/
npm-publish-from-pr.yml
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
name: npm publish from PR
on:
workflow_dispatch:
inputs:
repo:
description: 'source gh repo, like `google/zx`'
required: true
commit:
description: 'commit id'
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.commit }}
- name: Build
run: |
npm ci
npm run build
- uses: actions/upload-artifact@v4
with:
name: build-pr-${{ github.run_id }}
path: |
target
package.json
README.md
buildstamp.json
retention-days: 1
publish:
needs: build
runs-on: ubuntu-latest
permissions:
checks: read
statuses: write
contents: write
packages: write
id-token: write
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/download-artifact@v4
with:
name: build-pr-${{ github.run_id }}
- run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Notice
if: github.event.inputs.repo != github.repository
run: node -e "const fs = require('fs'); fs.writeFileSync('./README.md', process.env.NOTICE + fs.readFileSync('./README.md'))"
env:
NOTICE: "> ⚠<fe0f> **This snapshot was built from the external source** \n> repo: ${{ github.event.inputs.repo }} \n> commit: ${{ github.event.inputs.commit }}\n"
- run: |
npm version $(node --eval="process.stdout.write(require('./package.json').version)")-pr.${{ github.run_id }} --no-git-tag-version
npm publish --provenance --access=public --no-git-tag-version --tag pr