FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: npm release · NativeScript/font-manager@f6caccb · GitHub

Repository navigation

Commit f6caccb

Browse files
committed
feat: npm release
1 parent 18842e1 commit f6caccb

2 files changed

Lines changed: 89 additions & 3 deletions

File tree

‎.github/workflows/npm_release.yml‎

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Publishes @nativescript/font-manager to npm from an existing SPM release tag,
2+
# so the packaged nativescript.config.ts always points at a resolvable
3+
# FontManager.xcframework release.
4+
#
5+
# Triggered automatically at the end of the SPM Release workflow, or manually
6+
# via workflow_dispatch. Requires an NPM_TOKEN secret with publish rights to
7+
# @nativescript/font-manager.
8+
name: npm Release
9+
10+
on:
11+
workflow_dispatch:
12+
inputs:
13+
version:
14+
description: 'Version to publish (e.g. 1.0.12). Must match an existing SPM release tag. Defaults to packages/font-manager/package.json.'
15+
required: false
16+
type: string
17+
18+
permissions:
19+
contents: read
20+
id-token: write # npm provenance
21+
22+
concurrency:
23+
group: npm-release
24+
cancel-in-progress: false
25+
26+
jobs:
27+
publish:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Resolve version
35+
id: version
36+
run: |
37+
VERSION="${{ github.event.inputs.version }}"
38+
if [ -z "$VERSION" ]; then
39+
VERSION="$(node -p "require('./packages/font-manager/package.json').version")"
40+
fi
41+
if ! git rev-parse -q --verify "refs/tags/$VERSION^{commit}" > /dev/null; then
42+
echo "error: tag $VERSION not found — run the SPM Release workflow first" >&2
43+
exit 1
44+
fi
45+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
46+
47+
- name: Checkout release tag
48+
run: git checkout "refs/tags/${{ steps.version.outputs.version }}"
49+
50+
- uses: actions/setup-node@v4
51+
with:
52+
node-version: 22
53+
registry-url: 'https://registry.npmjs.org'
54+
55+
- name: Install dependencies
56+
run: npm ci
57+
58+
- name: Build and publish @nativescript/font-manager
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
NPM_CONFIG_PROVENANCE: true
62+
run: npx nx g @nativescript/plugin-tools:publish font-manager --version="${{ steps.version.outputs.version }}" --verify --no-interactive
63+
64+
- name: Verify npm publish
65+
run: |
66+
VERSION="${{ steps.version.outputs.version }}"
67+
for i in $(seq 1 10); do
68+
if [ "$(npm view "@nativescript/font-manager@$VERSION" version 2>/dev/null)" = "$VERSION" ]; then
69+
echo "@nativescript/font-manager@$VERSION is live"
70+
exit 0
71+
fi
72+
echo "not visible yet, retrying ($i/10)..."
73+
sleep 15
74+
done
75+
echo "error: @nativescript/font-manager@$VERSION not visible on the registry" >&2
76+
exit 1

‎.github/workflows/spm_release.yml‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Prebuilds FontManager.xcframework, publishes it as a GitHub release, and
22
# stamps the URL + checksum into Package.swift and nativescript.config.ts.
33
#
4-
# After it runs, pull main and publish to npm as usual
5-
# (npm run publish-packages) with the same version.
4+
# On success it dispatches the npm Release workflow, which publishes
5+
# @nativescript/font-manager from the tag it created.
66
name: SPM Release
77

88
on:
@@ -15,6 +15,7 @@ on:
1515

1616
permissions:
1717
contents: write
18+
actions: write # dispatch npm_release.yml
1819

1920
concurrency:
2021
group: spm-release
@@ -62,11 +63,15 @@ jobs:
6263
- name: Stamp Package.swift and nativescript.config.ts
6364
run: node tools/scripts/stamp-spm-release.mjs "${{ steps.version.outputs.version }}" "$(cat dist/spm/FontManager.xcframework.zip.checksum)"
6465

66+
- name: Stamp package.json version
67+
working-directory: packages/font-manager
68+
run: npm version "${{ steps.version.outputs.version }}" --no-git-tag-version --allow-same-version
69+
6570
- name: Commit and tag
6671
run: |
6772
git config user.name "github-actions[bot]"
6873
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
69-
git add Package.swift packages/font-manager/nativescript.config.ts
74+
git add Package.swift packages/font-manager/nativescript.config.ts packages/font-manager/package.json
7075
git commit -m "release: FontManager.xcframework ${{ steps.version.outputs.version }}"
7176
git pull --rebase origin main
7277
git tag "${{ steps.version.outputs.version }}"
@@ -101,3 +106,8 @@ jobs:
101106
)
102107
EOF
103108
cd /tmp/spm-verify && swift package resolve
109+
110+
- name: Trigger npm release
111+
env:
112+
GH_TOKEN: ${{ github.token }}
113+
run: gh workflow run npm_release.yml --ref main -f version="${{ steps.version.outputs.version }}"

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL