Skip to content

Commit 8cab4a2

Browse files
committed
ci(github-actions): add npm publish workflow
1 parent e556411 commit 8cab4a2

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- "codetime@*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: "npm dist-tag (default: latest)"
11+
required: false
12+
default: latest
13+
14+
jobs:
15+
publish:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
id-token: write # required for npm trusted publishing (OIDC)
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v4
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 22
31+
registry-url: "https://registry.npmjs.org"
32+
cache: pnpm
33+
34+
# npm >= 11.5.1 is required for trusted publishing (OIDC)
35+
- name: Upgrade npm
36+
run: npm install -g npm@latest
37+
38+
- name: Install dependencies
39+
run: pnpm install --frozen-lockfile
40+
41+
- name: Run tests
42+
run: pnpm test
43+
44+
- name: Bundle CLI
45+
run: pnpm --filter codetime-cli run build:bundle
46+
47+
# pnpm pack rewrites `workspace:*` to concrete versions in the tarball;
48+
# npm publish then uploads with OIDC (trusted publishing + provenance).
49+
- name: Pack tarball
50+
working-directory: packages/cli
51+
run: pnpm pack --pack-destination .
52+
53+
- name: Publish to npm
54+
working-directory: packages/cli
55+
run: npm publish codetime-cli-*.tgz --access public --tag "${{ github.event.inputs.tag || 'latest' }}"

0 commit comments

Comments
 (0)