Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7737d20

Browse files
committed
refactor(release): consolidate release workflow into node.js.yml and remove redundant release.yml
1 parent ef0542c commit 7737d20

File tree

2 files changed

+24
-86
lines changed

2 files changed

+24
-86
lines changed

.github/workflows/node.js.yml

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ on:
99
pull_request:
1010
branches: [main]
1111
workflow_dispatch:
12+
inputs:
13+
version:
14+
description: "Version type (auto-detects from package.json if not specified)"
15+
required: false
16+
type: choice
17+
options:
18+
- ""
19+
- patch
20+
- minor
21+
- major
1222

1323
jobs:
1424
lint:
@@ -46,21 +56,21 @@ jobs:
4656
needs: [lint, build]
4757
if: ${{ github.event_name == 'workflow_dispatch' }}
4858
permissions:
49-
contents: write
50-
packages: write
59+
id-token: write # Required for OIDC
60+
contents: write # Required for release-it to create tags/commits
5161
steps:
5262
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
5363
with:
54-
# Fetch all history for proper versioning
55-
fetch-depth: 0
64+
fetch-depth: 0 # Need full history for release-it
5665

57-
- name: Use Node.js 20
58-
uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1
66+
# setup-node with registry-url is required for OIDC trusted publishing
67+
- uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1
5968
with:
60-
node-version: "20"
69+
node-version: 20
70+
cache: "npm"
6171
registry-url: "https://registry.npmjs.org"
6272

63-
- name: Setup SSH Bot
73+
- name: Set up SSH signing
6474
uses: photostructure/git-ssh-signing-action@a770c2ff3aea31d9df9f2974ac9d672f2bfe62f3 # v1.1.0
6575
with:
6676
ssh-signing-key: ${{ secrets.SSH_SIGNING_KEY }}
@@ -70,30 +80,10 @@ jobs:
7080
- name: Install dependencies
7181
run: npm ci
7282

73-
- name: Build and test
74-
run: npm test
75-
76-
- name: Create release
77-
run: |
78-
# Bump version and create signed commit and tag
79-
npm version patch -m "release: %s"
80-
81-
# Push the version commit and tag
82-
git push --follow-tags
83-
84-
- name: Publish to npm
85-
run: npm publish
86-
env:
87-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
88-
89-
- name: Create GitHub release
90-
run: |
91-
# Get the version from package.json
92-
VERSION=$(node -p "require('./package.json').version")
93-
94-
# Create GitHub release
95-
gh release create "v${VERSION}" \
96-
--title "Release v${VERSION}" \
97-
--generate-notes
83+
# Note: Tests are run by release-it's before:init hook via npm run lint -> pretest
84+
# This avoids running the full test matrix (9+ OS/Node combinations) in the release workflow
85+
# The pretest script (clean + lint + compile) is sufficient for release validation
86+
- name: Release with release-it
87+
run: npm run release -- --ci ${{ github.event.inputs.version }}
9888
env:
99-
GH_TOKEN: ${{ github.token }}
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)