Skip to content

Commit b103c1f

Browse files
Mirror releases to GitHub Packages
1 parent 6282621 commit b103c1f

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: GitHub Packages
2+
3+
# Mirrors published releases to GitHub Packages (npm.pkg.github.com) so the
4+
# package is listed on the organization packages page. The primary registry
5+
# remains npmjs.org; this publication is a courtesy mirror. Runs automatically
6+
# when a GitHub release is published and can be triggered manually for an
7+
# existing tag.
8+
on:
9+
release:
10+
types: [published]
11+
workflow_dispatch:
12+
inputs:
13+
tag:
14+
description: 'Existing release tag to publish, e.g. v6.0.1'
15+
required: true
16+
type: string
17+
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
jobs:
23+
publish:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Determine and validate tag
27+
# The raw value is passed through the environment (never interpolated
28+
# into the shell) and strictly validated before being used as a ref.
29+
env:
30+
TAG_INPUT: ${{ inputs.tag || github.event.release.tag_name }}
31+
run: |
32+
set -euo pipefail
33+
if ! printf '%s' "$TAG_INPUT" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$'; then
34+
echo "::error::Invalid tag '$TAG_INPUT'. Expected a tag such as v1.2.0."
35+
exit 1
36+
fi
37+
echo "TAG=$TAG_INPUT" >> "$GITHUB_ENV"
38+
39+
- uses: actions/checkout@v7
40+
with:
41+
ref: ${{ env.TAG }}
42+
43+
- name: Use Node.js
44+
uses: actions/setup-node@v6
45+
with:
46+
node-version: 24.x
47+
registry-url: 'https://npm.pkg.github.com'
48+
49+
- name: Install dependencies
50+
run: npm install
51+
52+
- name: Publish to GitHub Packages
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: npm publish

0 commit comments

Comments
 (0)