-
Notifications
You must be signed in to change notification settings - Fork 1
51 lines (41 loc) · 1.78 KB
/
publish-gpr.yml
File metadata and controls
51 lines (41 loc) · 1.78 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
name: Publish to GitHub Packages
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Verify release tag matches package version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
node -e "const fs=require('fs');const v=JSON.parse(fs.readFileSync('package.json','utf8')).version;const t=(process.env.RELEASE_TAG||'').replace(/^v/,'');if(!t){console.error('Missing release tag');process.exit(1)};if(t!==v){console.error(`Release tag (${process.env.RELEASE_TAG}) does not match package.json version (${v})`);process.exit(1)};console.log(`Version OK: ${v}`);"
- name: Build
run: npm run build
# GitHub Packages npm registry requires a scoped package name that matches the owner/org.
# We scope it only at publish-time so the source package name can stay unscoped for npmjs.org if desired.
- name: Scope package name for GitHub Packages
run: |
node -e "const fs=require('fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.name='@chartgpu/chartgpu-react';fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\n');"
- name: Configure npm for GitHub Packages
uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: "https://npm.pkg.github.com"
- name: Publish
run: npm publish --registry=https://npm.pkg.github.com
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}