mirror of
https://github.com/Warky-Devs/artemis-kit.git
synced 2026-11-10 06:18:47 +00:00
ci(publish): update workflow to include release tag verification
This commit is contained in:
1 parent
107ca70d0f
commit
c82b88bfa2
1 file changed
+46
-5
@@ -4,6 +4,12 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
release_tag:
|
||||||
|
description: Existing tag to publish (must match package.json version, e.g. v1.1.0)
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
id-token: write # Required for OIDC
|
id-token: write # Required for OIDC
|
||||||
@@ -14,13 +20,48 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
ref: ${{ inputs.release_tag || github.ref }}
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
registry-url: "https://registry.npmjs.org"
|
registry-url: "https://registry.npmjs.org"
|
||||||
package-manager-cache: false # never use caching in release builds
|
scope: "@warkypublic"
|
||||||
- run: npm ci
|
cache: pnpm
|
||||||
- run: npm run build --if-present
|
|
||||||
- run: npm test
|
- name: Verify release tag
|
||||||
- run: npm publish # Or: npm stage publish
|
env:
|
||||||
|
EVENT_NAME: ${{ github.event_name }}
|
||||||
|
TRIGGER_REF: ${{ github.ref }}
|
||||||
|
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||||
|
run: |
|
||||||
|
node --input-type=module <<'JS'
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
|
const { version } = JSON.parse(readFileSync('package.json', 'utf8'));
|
||||||
|
const tag = process.env.EVENT_NAME === 'workflow_dispatch'
|
||||||
|
? process.env.RELEASE_TAG
|
||||||
|
: process.env.TRIGGER_REF.replace(/^refs\/tags\//, '');
|
||||||
|
if (tag !== `v${version}`) {
|
||||||
|
throw new Error(`Release tag must be v${version}; received ${tag || '(empty)'}`);
|
||||||
|
}
|
||||||
|
JS
|
||||||
|
|
||||||
|
- run: pnpm install --frozen-lockfile
|
||||||
|
- run: pnpm test
|
||||||
|
- run: pnpm check:bundle
|
||||||
|
|
||||||
|
- name: Publish to npm
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
: "${NODE_AUTH_TOKEN:?Set the NPM_TOKEN Actions secret with npm publish access}"
|
||||||
|
version=$(node -p "require('./package.json').version")
|
||||||
|
case "$version" in
|
||||||
|
*-*) dist_tag=next ;;
|
||||||
|
*) dist_tag=latest ;;
|
||||||
|
esac
|
||||||
|
pnpm publish --no-git-checks --tag "$dist_tag"
|
||||||
Reference in new issue
Block a user