-
Notifications
You must be signed in to change notification settings - Fork 1.5k
63 lines (55 loc) · 1.79 KB
/
Copy pathrelease-goal-init.yml
File metadata and controls
63 lines (55 loc) · 1.79 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
58
59
60
61
62
63
name: Release goal-init
on:
push:
tags:
- 'goal-init-v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to publish (e.g. goal-init-v1.0.0)'
required: true
type: string
permissions:
contents: read
id-token: write
jobs:
test-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && format('refs/tags/{0}', github.event.inputs.tag) || github.ref }}
- uses: actions/setup-node@v7
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
cache-dependency-path: tools/goal-init/package-lock.json
- name: Ensure npm supports trusted publishing (OIDC)
run: npm install -g npm@latest
- name: Install, build, test
working-directory: tools/goal-init
run: |
npm ci
npm run build
npm test
- name: Skip if version already published
id: check
working-directory: tools/goal-init
run: |
VERSION=$(node -p "require('./package.json').version")
if npm view "@cobusgreyling/goal-init@${VERSION}" version 2>/dev/null; then
echo "Version ${VERSION} already on npm — skipping publish."
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "Publishing @cobusgreyling/goal-init@${VERSION}"
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
if: steps.check.outputs.skip != 'true'
working-directory: tools/goal-init
run: npm publish --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}