diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5465e92..9eff1ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,11 @@ on: required: true type: string default: next + publish: + description: Publish to npm (off packs the tarball as an artifact only) + required: true + type: boolean + default: true push: tags: - 'v*' @@ -126,7 +131,7 @@ jobs: - name: Install Node with the npm registry uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 with: - node-version: 22 + node-version: 24 registry-url: https://registry.npmjs.org - name: Download the iOS artifacts @@ -200,10 +205,16 @@ jobs: exit 1 fi - - name: List the tarball contents - run: npm pack --dry-run 2>&1 | tee pack-dry-run.log + - name: Pack the tarball + run: npm pack 2>&1 | tee pack.log - - name: Publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npm publish --provenance --access public --tag "${{ steps.dist.outputs.tag }}" + - name: Upload the tarball + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: npm-tarball + path: kilocode-react-native-ssh-*.tgz + retention-days: 7 + + - name: Publish through npm trusted publishing + if: github.event_name == 'push' || inputs.publish + run: npm publish ./kilocode-react-native-ssh-*.tgz --access public --tag "${{ steps.dist.outputs.tag }}" diff --git a/README.md b/README.md index 73dae1f..1f1e989 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,17 @@ runs on a `v*` tag or by hand with a `dist-tag` input (default `next`): 1. macOS runs `scripts/build-ios.sh` and uploads `ios/`. 2. Linux runs `scripts/build-android.sh` and uploads the jniLibs and the Kotlin bindings. -3. One job downloads both into the checkout, runs `npm run build`, lists - `npm pack --dry-run`, asserts the xcframework slices, both `.so` files, the - Kotlin and Swift bindings and the compiled `build/` are present, then runs - `npm publish --provenance --access public --tag `. - -The publish job needs an `NPM_TOKEN` secret with write access to `@kilocode` and -`id-token: write` for the provenance attestation. A tag must equal the +3. One job downloads both into the checkout, runs `npm run build`, asserts the + xcframework slices, both `.so` files, the Kotlin and Swift bindings and the + compiled `build/` are present, packs the tarball, uploads it as the + `npm-tarball` artifact and publishes it with + `npm publish --access public --tag `. + +Publishing uses npm trusted publishing: the job's `id-token: write` permission +lets npm exchange a GitHub OIDC token for a short-lived publish credential and +attach a provenance attestation, so no npm token is stored. The package's +trusted publisher on npmjs.com names this repository and `release.yml`. A manual +run with `publish` off only packs the tarball. A tag must equal the `package.json` version with a `v` prefix; a tag containing a hyphen publishes under `next`, any other tag under `latest`.