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..b606c9c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,28 +1,42 @@ -# 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: Stage npm release on: release: - types: [created] + types: [published] + +permissions: + contents: read + id-token: write jobs: - publish-npm: + stage-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: 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 + 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: Stage tarball for manual approval + # The trusted publisher only needs the npm stage publish permission. env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + NPM_DIST_TAG: ${{ github.event.release.prerelease && 'next' || 'latest' }} + run: npm stage 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"