Skip to content

Commit ad82ba9

Browse files
authored
feat: pub to github packages (#16)
1 parent d488131 commit ad82ba9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/publish-gpr.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish to GitHub Packages
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
publish-gpr:
8+
name: Publish to GitHub Packages
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
packages: write
13+
steps:
14+
- name: Parse tag
15+
id: parse
16+
run: |
17+
TAG="${{ github.ref_name }}"
18+
# Extract package name and version from tag like @cometloop/safe@0.1.0
19+
NAME="${TAG%@*}"
20+
VERSION="${TAG##*@}"
21+
DIR="packages/${NAME#@cometloop/}"
22+
echo "name=${NAME}" >> "$GITHUB_OUTPUT"
23+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
24+
echo "dir=${DIR}" >> "$GITHUB_OUTPUT"
25+
echo "Publishing ${NAME}@${VERSION} from ${DIR}"
26+
27+
- uses: actions/checkout@v4
28+
29+
- uses: pnpm/action-setup@v4
30+
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: 22
34+
cache: pnpm
35+
36+
- run: pnpm install --frozen-lockfile
37+
38+
- run: pnpm --filter "${{ steps.parse.outputs.name }}" build
39+
40+
- name: Publish to GitHub Packages
41+
run: |
42+
echo "@cometloop:registry=https://npm.pkg.github.com" > "$RUNNER_TEMP/.npmrc_gpr"
43+
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" >> "$RUNNER_TEMP/.npmrc_gpr"
44+
45+
npm publish "./${{ steps.parse.outputs.dir }}" \
46+
--userconfig="$RUNNER_TEMP/.npmrc_gpr" \
47+
--provenance=false \
48+
--access=public
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)