Skip to content

version: v0.3.1

version: v0.3.1 #4

Workflow file for this run

name: Publish to npm
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
dist_tag:
description: npm dist-tag channel (latest / beta / next). Git tag is auto-selected.
required: false
default: latest
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # required for npm trusted publishing (OIDC)
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
# On manual dispatch, jump to the latest `v*` tag so we always
# publish the most recent release rather than whatever is on the branch.
- name: Checkout latest tag (manual dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
latest_tag=$(git tag --list 'v*' --sort=-v:refname | head -n 1)
if [ -z "$latest_tag" ]; then
echo "no v* tag found" >&2
exit 1
fi
echo "checking out $latest_tag"
git checkout "refs/tags/$latest_tag"
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'
cache: pnpm
# npm >= 11.5.1 is required for trusted publishing (OIDC).
# Install into a separate prefix first to avoid the self-overwrite
# MODULE_NOT_FOUND bug seen when npm rewrites its own files in place.
- name: Upgrade npm
run: |
npm install --prefix "$RUNNER_TEMP/npm-upgrade" npm@latest
echo "$RUNNER_TEMP/npm-upgrade/node_modules/.bin" >> "$GITHUB_PATH"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run tests
run: pnpm test
- name: Bundle CLI
run: pnpm --filter codetime-cli run build:bundle
# pnpm pack rewrites `workspace:*` to concrete versions in the tarball;
# npm publish then uploads with OIDC (trusted publishing + provenance).
- name: Pack tarball
working-directory: packages/cli
run: pnpm pack --pack-destination .
- name: Publish to npm
working-directory: packages/cli
run: npm publish codetime-cli-*.tgz --access public --tag "${{ github.event.inputs.dist_tag || 'latest' }}"