From 53cb15bab12b0137ea7aa3e7d2bb2bd18ce74257 Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Thu, 5 Feb 2026 22:31:55 +0900 Subject: [PATCH] =?UTF-8?q?CI:=20auto-tag=20=E3=81=AB=20publish=20?= =?UTF-8?q?=E3=82=B8=E3=83=A7=E3=83=96=E3=82=92=E7=B5=B1=E5=90=88=E3=80=81?= =?UTF-8?q?publish.yml=20=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-tag.yml | 36 +++++++++++++++++++++++++++++++++- .github/workflows/publish.yml | 34 -------------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/auto-tag.yml b/.github/workflows/auto-tag.yml index 1148bd0..bab7fad 100644 --- a/.github/workflows/auto-tag.yml +++ b/.github/workflows/auto-tag.yml @@ -1,4 +1,4 @@ -name: Auto Tag on Release PR Merge +name: Auto Tag & Publish on Release PR Merge on: pull_request: @@ -14,6 +14,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + outputs: + tag: ${{ steps.version.outputs.tag }} steps: - uses: actions/checkout@v4 @@ -27,3 +29,35 @@ jobs: run: | git tag "${{ steps.version.outputs.tag }}" git push origin "${{ steps.version.outputs.tag }}" + + publish: + needs: tag + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ needs.tag.outputs.tag }} + + - uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + + - run: npm ci + - run: npm run build + - run: npm test + + - name: Determine npm tag + id: npm-tag + run: | + VERSION="${{ needs.tag.outputs.tag }}" + VERSION="${VERSION#v}" + if echo "$VERSION" | grep -qE '(alpha|beta|rc|next)'; then + echo "tag=next" >> "$GITHUB_OUTPUT" + else + echo "tag=latest" >> "$GITHUB_OUTPUT" + fi + + - run: npm publish --tag ${{ steps.npm-tag.outputs.tag }} + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 0a4a2c1..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Publish to npm - -on: - push: - tags: - - 'v*' - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version: '20' - registry-url: 'https://registry.npmjs.org' - - - run: npm ci - - run: npm run build - - run: npm test - - name: Determine npm tag - id: npm-tag - run: | - VERSION="${GITHUB_REF#refs/tags/v}" - if echo "$VERSION" | grep -qE '(alpha|beta|rc|next)'; then - echo "tag=next" >> "$GITHUB_OUTPUT" - else - echo "tag=latest" >> "$GITHUB_OUTPUT" - fi - - - run: npm publish --tag ${{ steps.npm-tag.outputs.tag }} - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}