-
Notifications
You must be signed in to change notification settings - Fork 3
56 lines (50 loc) · 1.64 KB
/
Copy pathpublish-github-package.yml
File metadata and controls
56 lines (50 loc) · 1.64 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
name: Publish GitHub npm package
on:
push:
branches:
- main
paths:
- .github/workflows/publish-github-package.yml
workflow_dispatch:
inputs:
version:
description: npmjs version to mirror
required: true
default: "1.0.5"
permissions:
contents: read
packages: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://npm.pkg.github.com
- name: Download the verified npmjs package
env:
VERSION: ${{ inputs.version || '1.0.5' }}
run: |
mkdir -p publish-source
npm pack "beauticode-dsh@${VERSION}" --registry=https://registry.npmjs.org --pack-destination publish-source
tar -xzf publish-source/*.tgz -C publish-source --strip-components=1
- name: Scope the package for GitHub Packages
run: |
node <<'NODE'
const fs = require("node:fs");
const file = "publish-source/package.json";
const pkg = JSON.parse(fs.readFileSync(file, "utf8"));
pkg.name = "@starsstreaming/beauticode-dsh";
pkg.publishConfig = {
...(pkg.publishConfig || {}),
access: "public",
registry: "https://npm.pkg.github.com",
};
fs.writeFileSync(file, JSON.stringify(pkg, null, 2) + "\n");
NODE
- name: Publish to GitHub Packages
run: npm publish ./publish-source --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}