-
Notifications
You must be signed in to change notification settings - Fork 3
55 lines (48 loc) · 1.73 KB
/
Copy pathgithub-packages.yaml
File metadata and controls
55 lines (48 loc) · 1.73 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
name: GitHub Packages
# Mirrors published releases to GitHub Packages (npm.pkg.github.com) so the
# package is listed on the organization packages page. The primary registry
# remains npmjs.org; this publication is a courtesy mirror. Dispatched by the
# Release workflow after a successful release (a `release: published` trigger
# would never fire, since releases are created with GITHUB_TOKEN and GitHub
# suppresses workflow triggers from such events) and can be triggered manually
# for an existing tag.
on:
workflow_dispatch:
inputs:
tag:
description: 'Existing release tag to publish, e.g. v6.0.1'
required: true
type: string
permissions:
contents: read
packages: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Determine and validate tag
# The raw value is passed through the environment (never interpolated
# into the shell) and strictly validated before being used as a ref.
env:
TAG_INPUT: ${{ inputs.tag }}
run: |
set -euo pipefail
if ! printf '%s' "$TAG_INPUT" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$'; then
echo "::error::Invalid tag '$TAG_INPUT'. Expected a tag such as v1.2.0."
exit 1
fi
echo "TAG=$TAG_INPUT" >> "$GITHUB_ENV"
- uses: actions/checkout@v7
with:
ref: ${{ env.TAG }}
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: 24.x
registry-url: 'https://npm.pkg.github.com'
- name: Install dependencies
run: npm install
- name: Publish to GitHub Packages
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm publish