From 0f82186d33f2f09835569e73d99dbf10460e5741 Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Mon, 20 Oct 2025 20:38:06 +0200 Subject: [PATCH] Split tag creation and publishing to NPM into separate flows --- .github/workflows/create-tag.yml | 58 ++++++++++++++++++++++++++++++++ .github/workflows/publish.yml | 43 ++--------------------- 2 files changed, 61 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/create-tag.yml diff --git a/.github/workflows/create-tag.yml b/.github/workflows/create-tag.yml new file mode 100644 index 0000000..b122002 --- /dev/null +++ b/.github/workflows/create-tag.yml @@ -0,0 +1,58 @@ +name: Create tag + +on: + workflow_dispatch: + inputs: + bump: + description: 'Version bump type' + required: true + default: 'minor' + type: choice + options: + - patch + - minor + - major + + push: + branches: + - main + paths: + - 'package.json' + - 'index.js' + +jobs: + create-tag: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v5 + with: + token: ${{ secrets.GH_PUSH_TOKEN }} + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: '22' + registry-url: 'https://registry.npmjs.org' + + - name: Update npm + run: npm install -g npm@latest + + - name: Install dependencies + run: npm install + + - name: Verifying provenance attestations + run: npm audit signatures + + - name: Bump version and create tag + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + npm version ${{ github.event.inputs.bump || 'minor' }} -m "Release %s" + + - name: Dry run publishing to npm + run: npm publish --dry-run --provenance --access=public + + - name: Push to GitHub + run: git push origin main --follow-tags diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e67ce94..7e0a3a6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,24 +1,9 @@ name: Publish to npm on: - workflow_dispatch: - inputs: - bump: - description: 'Version bump type' - required: true - default: 'minor' - type: choice - options: - - patch - - minor - - major - push: - branches: - - main - paths: - - 'package.json' - - 'index.js' + tags: + - 'v*' permissions: id-token: write @@ -31,8 +16,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v5 - with: - token: ${{ secrets.GH_PUSH_TOKEN }} - name: Set up Node.js uses: actions/setup-node@v6 @@ -40,32 +23,12 @@ jobs: node-version: '22' registry-url: 'https://registry.npmjs.org' - - name: Update npm - run: npm install -g npm@latest - - - name: Install dependencies - run: npm install - - - name: Verifying provenance attestations - run: npm audit signatures - - - name: Bump version and create tag - id: bump-version - run: | - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - TAG=$(npm version ${{ github.event.inputs.bump || 'minor' }} -m "Release %s [skip ci]") - echo "Created tag: $TAG" - echo "tag=$TAG" >> "$GITHUB_OUTPUT" - git push origin main --follow-tags - - name: Publish to npm - run: npm publish --provenance --access=public + run: npm publish --dry-run --provenance --access=public - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: - tag_name: ${{ steps.bump-version.outputs.tag }} generate_release_notes: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}