| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff 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 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,8 @@ | |||
| 1 | 1 | # Prebuilds FontManager.xcframework, publishes it as a GitHub release, and | |
| 2 | 2 | # stamps the URL + checksum into Package.swift and nativescript.config.ts. | |
| 3 | 3 | # | |
| 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. | ||
| 6 | 6 | name: SPM Release | |
| 7 | 7 | ||
| 8 | 8 | on: | |
@@ -15,6 +15,7 @@ on: | |||
| 15 | 15 | ||
| 16 | 16 | permissions: | |
| 17 | 17 | contents: write | |
| 18 | + actions: write # dispatch npm_release.yml | ||
| 18 | 19 | ||
| 19 | 20 | concurrency: | |
| 20 | 21 | group: spm-release | |
@@ -62,11 +63,15 @@ jobs: | |||
| 62 | 63 | - name: Stamp Package.swift and nativescript.config.ts | |
| 63 | 64 | run: node tools/scripts/stamp-spm-release.mjs "${{ steps.version.outputs.version }}" "$(cat dist/spm/FontManager.xcframework.zip.checksum)" | |
| 64 | 65 | ||
| 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 | + | ||
| 65 | 70 | - name: Commit and tag | |
| 66 | 71 | run: | | |
| 67 | 72 | git config user.name "github-actions[bot]" | |
| 68 | 73 | 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 | ||
| 70 | 75 | git commit -m "release: FontManager.xcframework ${{ steps.version.outputs.version }}" | |
| 71 | 76 | git pull --rebase origin main | |
| 72 | 77 | git tag "${{ steps.version.outputs.version }}" | |
@@ -101,3 +106,8 @@ jobs: | |||
| 101 | 106 | ) | |
| 102 | 107 | EOF | |
| 103 | 108 | 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 }}" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments