From c9de396dbb4f69ea5ef7403221e28c5211dd9add Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Thu, 27 Aug 2026 11:07:51 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20npm=20release=20via=20Trusted=20Publishin?= =?UTF-8?q?g=20(OIDC,=20no=20token)=20=E2=80=94=20the=20token=20path=20E40?= =?UTF-8?q?4s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 47 ++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9dd23f1..e4c5deb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,28 +1,57 @@ -name: release +name: Release on: push: tags: - "v*" + workflow_dispatch: + inputs: + version: + description: "Version to release (e.g. 0.1.1)" + required: true + type: string permissions: - contents: read - id-token: write # required for npm provenance + id-token: write + contents: write jobs: publish: runs-on: ubuntu-latest - environment: release steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 with: - node-version: "22" - cache: npm - registry-url: https://registry.npmjs.org + node-version: "24" + registry-url: "https://registry.npmjs.org" - run: npm ci + - run: npm run lint + - run: npm run format:check - run: npm run build - run: npm test + - name: Set version from workflow input + if: github.event_name == "workflow_dispatch" + run: | + current=$(node -p "require('./package.json').version") + if [ "$current" != "${{ inputs.version }}" ]; then + npm version ${{ inputs.version }} --no-git-tag-version + fi - run: npm publish --provenance --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.INTERSCRIPT_NPM_TOKEN }} + + github-release: + needs: publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - name: Determine version + id: version + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "tag=v${{ inputs.version }}" >> "$GITHUB_OUTPUT" + else + echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" + fi + - uses: softprops/action-gh-release@v3 + with: + tag_name: ${{ steps.version.outputs.tag }} + generate_release_notes: true