From dd0e8628a9312a3a5c620218ceca2e8ef5f0917c Mon Sep 17 00:00:00 2001 From: Nathan Ahn Date: Wed, 28 Oct 2026 13:56:03 -0400 Subject: [PATCH 1/2] Fixing CI publishing --- .github/workflows/ci.yml | 20 ++++++++++---- .github/workflows/npm-publish.yml | 44 ++++++++++++++++++++----------- package.json | 7 ++--- 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ce79d8..031c12d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,15 +5,25 @@ on: - main pull_request: +permissions: + contents: read + jobs: CI: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: "24" + package-manager-cache: false - name: Setup Bun - uses: oven-sh/setup-bun@v1 + uses: oven-sh/setup-bun@v2 - name: Install dependencies - run: bun install - - name: Build react-native-app-clip - run: bun run build + run: bun install --frozen-lockfile + - name: Build and pack package + run: | + mkdir -p "$RUNNER_TEMP/npm-package" + npm pack --pack-destination "$RUNNER_TEMP/npm-package" diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 67238b0..ae6359f 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,28 +1,40 @@ -# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created -# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages - -name: Node.js Package +name: Publish to npm on: release: - types: [created] + types: [published] + +permissions: + contents: read + id-token: write jobs: publish-npm: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 - - name: Setup Bun - uses: oven-sh/setup-bun@v1 - - name: Install dependencies - run: bun install - - name: Build package - run: bun run build - - uses: actions/setup-node@v4 + uses: actions/checkout@v6 + - name: Setup Node.js + uses: actions/setup-node@v6 with: - node-version: "20.x" + node-version: "24" registry-url: "https://registry.npmjs.org" - - run: npm publish + package-manager-cache: false + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + - name: Verify release version + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + run: | + node -e 'const { version } = require("./package.json"); if (process.env.RELEASE_TAG !== "v" + version) throw new Error("Release tag must match package.json: v" + version);' + - name: Install dependencies + run: bun install --frozen-lockfile + - name: Build and pack package + run: | + mkdir -p "$RUNNER_TEMP/npm-package" + npm pack --pack-destination "$RUNNER_TEMP/npm-package" + - name: Publish tarball + # Register npm-publish.yml as a trusted publisher in the npm package settings. env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + NPM_DIST_TAG: ${{ github.event.release.prerelease && 'next' || 'latest' }} + run: npm publish "$RUNNER_TEMP/npm-package/"*.tgz --access public --tag "$NPM_DIST_TAG" diff --git a/package.json b/package.json index 2b2c858..40a4f1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "react-native-app-clip", "version": "0.9.2", + "packageManager": "bun@1.4.3", "description": "Config plugin to add an App Clip to a React Native iOS app", "main": "build/index.js", "types": "build/index.d.ts", @@ -13,13 +14,13 @@ "app.plugin.js" ], "scripts": { - "build": "expo-module build", - "build:plugin": "expo-module build plugin", + "build": "expo-module build && npm run build:plugin", + "build:plugin": "expo-module build plugin --force", "clean": "expo-module clean", "lint": "expo-module lint", "test": "expo-module test", "prepare": "expo-module prepare", - "prepublishOnly": "expo-module prepublishOnly", + "prepack": "expo-module clean && expo-module clean plugin && npm run build", "expo-module": "expo-module", "open:ios": "xed example/ios", "open:android": "open -a \"Android Studio\" example/android" From cf6d39d65e70eb9a519e4478b849215a150cf03d Mon Sep 17 00:00:00 2001 From: Nathan Ahn Date: Wed, 28 Oct 2026 13:59:55 -0400 Subject: [PATCH 2/2] Staging publish only --- .github/workflows/npm-publish.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index ae6359f..b606c9c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,4 +1,4 @@ -name: Publish to npm +name: Stage npm release on: release: @@ -9,7 +9,7 @@ permissions: id-token: write jobs: - publish-npm: + stage-npm: runs-on: ubuntu-latest steps: - name: Checkout repository @@ -20,6 +20,8 @@ jobs: node-version: "24" registry-url: "https://registry.npmjs.org" package-manager-cache: false + - name: Install npm with staged publishing support + run: npm install --global npm@11.21.1 - name: Setup Bun uses: oven-sh/setup-bun@v2 - name: Verify release version @@ -33,8 +35,8 @@ jobs: run: | mkdir -p "$RUNNER_TEMP/npm-package" npm pack --pack-destination "$RUNNER_TEMP/npm-package" - - name: Publish tarball - # Register npm-publish.yml as a trusted publisher in the npm package settings. + - name: Stage tarball for manual approval + # The trusted publisher only needs the npm stage publish permission. env: NPM_DIST_TAG: ${{ github.event.release.prerelease && 'next' || 'latest' }} - run: npm publish "$RUNNER_TEMP/npm-package/"*.tgz --access public --tag "$NPM_DIST_TAG" + run: npm stage publish "$RUNNER_TEMP/npm-package/"*.tgz --access public --tag "$NPM_DIST_TAG"