Skip to content

Commit fbf8a74

Browse files
committed
ci: split manual npm package publishing workflow
1 parent 5168ab1 commit fbf8a74

3 files changed

Lines changed: 66 additions & 22 deletions

File tree

.github/workflows/on-release-published.yml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
name: 🌍 Release
2-
run-name: Release ${{ github.event.release.tag_name || github.event.inputs.version || github.ref_name }}
2+
run-name: Release ${{ github.event.release.tag_name }}
33

44
on:
5-
workflow_dispatch:
6-
inputs:
7-
version:
8-
description: 'Release tag to publish, for example 0.74.0'
9-
required: true
10-
type: string
11-
npm_only:
12-
description: 'Only publish the audited npm tarball for the selected release'
13-
required: false
14-
default: false
15-
type: boolean
165
release:
176
types: [published]
187

@@ -22,15 +11,14 @@ permissions:
2211
id-token: write
2312

2413
concurrency:
25-
group: release-publish-${{ github.event.release.tag_name || github.event.inputs.version || github.ref_name }}
14+
group: release-publish-${{ github.event.release.tag_name }}
2615
cancel-in-progress: false
2716

2817
env:
29-
RELEASE_TAG: ${{ github.event.release.tag_name || github.event.inputs.version || github.ref_name }}
18+
RELEASE_TAG: ${{ github.event.release.tag_name }}
3019

3120
jobs:
3221
deploy-website:
33-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.npm_only != 'true' }}
3422
runs-on: ubuntu-latest
3523
environment:
3624
name: github-pages
@@ -73,7 +61,6 @@ jobs:
7361
uses: actions/deploy-pages@v4
7462

7563
release-nuget:
76-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.npm_only != 'true' }}
7764
runs-on: ubuntu-latest
7865
steps:
7966
- name: Setup .NET
@@ -136,7 +123,6 @@ jobs:
136123
npm publish "${packages[0]}" --access public --provenance
137124
138125
publish-vscode-marketplace:
139-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.npm_only != 'true' }}
140126
runs-on: ubuntu-latest
141127
timeout-minutes: 15
142128
steps:
@@ -164,7 +150,6 @@ jobs:
164150
run: ./.github/scripts/publish-vscode-marketplace.sh
165151

166152
publish-open-vsx:
167-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.npm_only != 'true' }}
168153
runs-on: ubuntu-latest
169154
timeout-minutes: 15
170155
steps:
@@ -192,7 +177,6 @@ jobs:
192177
run: ./.github/scripts/publish-open-vsx.sh
193178

194179
sign-and-notarize:
195-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.npm_only != 'true' }}
196180
runs-on: macos-latest
197181
steps:
198182
- name: Download unsigned macOS artifacts
@@ -265,12 +249,11 @@ jobs:
265249
}
266250
267251
update-homebrew-tap:
268-
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.npm_only != 'true' }}
269252
uses: ./.github/workflows/release-homebrew-tap.yml
270253
needs:
271254
- sign-and-notarize
272255
with:
273-
ref: ${{ github.event.release.tag_name && format('refs/tags/{0}', github.event.release.tag_name) || github.event.inputs.version && format('refs/tags/{0}', github.event.inputs.version) || github.ref }}
274-
version: ${{ github.event.release.tag_name || github.event.inputs.version || github.ref_name }}
256+
ref: ${{ format('refs/tags/{0}', github.event.release.tag_name) }}
257+
version: ${{ github.event.release.tag_name }}
275258
dry-run: false
276259
secrets: inherit
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: 📦 Publish npm Package
2+
run-name: Publish npm package ${{ github.event.inputs.version }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Release tag to publish, for example 0.74.0'
9+
required: true
10+
type: string
11+
12+
permissions:
13+
contents: read
14+
id-token: write
15+
16+
concurrency:
17+
group: npm-publish-${{ github.event.inputs.version }}
18+
cancel-in-progress: false
19+
20+
jobs:
21+
publish-npm:
22+
runs-on: ubuntu-latest
23+
env:
24+
RELEASE_VERSION: ${{ github.event.inputs.version }}
25+
PACKAGE_NAME: '@magnusopera/fscript'
26+
steps:
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+
33+
- name: Download npm package artifact
34+
uses: robinraju/release-downloader@v1.11
35+
with:
36+
tag: ${{ env.RELEASE_VERSION }}
37+
fileName: '*.tgz'
38+
39+
- name: Publish npm package
40+
env:
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_KEY }}
42+
run: |
43+
if [[ -z "${NODE_AUTH_TOKEN:-}" ]]; then
44+
echo "::error::NPM_KEY secret is not configured."
45+
exit 1
46+
fi
47+
48+
shopt -s nullglob
49+
packages=(./*.tgz)
50+
if [[ "${#packages[@]}" -ne 1 ]]; then
51+
echo "::error::Expected exactly one audited npm .tgz release asset, found ${#packages[@]}."
52+
exit 1
53+
fi
54+
55+
if npm view "${PACKAGE_NAME}@${RELEASE_VERSION}" version >/dev/null 2>&1; then
56+
echo "${PACKAGE_NAME}@${RELEASE_VERSION} is already published; skipping."
57+
exit 0
58+
fi
59+
60+
npm publish "${packages[0]}" --access public --provenance

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ All notable changes to FScript are documented in this file.
44

55
## [Unreleased]
66

7+
- Split manual npm package publishing into a dedicated workflow so release publication automation only runs on published releases.
78
- Added npm publishing for the Fable JavaScript package when a release is published.
89
- Added npm package tarballs to draft release assets so the JavaScript package can be audited before publishing.
910

0 commit comments

Comments
 (0)