-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (48 loc) · 1.63 KB
/
Copy pathpublish-gpr.yml
File metadata and controls
57 lines (48 loc) · 1.63 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
57
name: Publish to GitHub Packages
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag to publish (e.g., @cometloop/safe@0.1.0)'
required: true
type: string
jobs:
publish-gpr:
name: Publish to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Parse tag
id: parse
run: |
TAG="${{ inputs.tag }}"
# Extract package name and version from tag like @cometloop/safe@0.1.0
NAME="${TAG%@*}"
VERSION="${TAG##*@}"
DIR="packages/${NAME#@cometloop/}"
echo "name=${NAME}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "dir=${DIR}" >> "$GITHUB_OUTPUT"
echo "Publishing ${NAME}@${VERSION} from ${DIR}"
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm --filter "${{ steps.parse.outputs.name }}" build
- name: Publish to GitHub Packages
run: |
echo "@cometloop:registry=https://npm.pkg.github.com" > "$RUNNER_TEMP/.npmrc_gpr"
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> "$RUNNER_TEMP/.npmrc_gpr"
npm publish "./${{ steps.parse.outputs.dir }}" \
--userconfig="$RUNNER_TEMP/.npmrc_gpr" \
--provenance=false \
--access=public
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}