Skip to content

Commit 9ba84de

Browse files
itsJess1caclaude
andcommitted
Separate CI and publish workflows
- Remove automatic publish from CI pipeline for better control - Create manual publish workflow (workflow_dispatch) with version bumping - CI now only runs: lint, format check, test, and build - Manual publish workflow includes: - Configurable version bump (patch/minor/major) - Optional test skipping - Automatic git tagging and GitHub releases - NPM publishing with proper access controls 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f7b57e2 commit 9ba84de

File tree

2 files changed

+104
-34
lines changed

2 files changed

+104
-34
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,4 @@ jobs:
4242
run: pnpm run test:run
4343

4444
- name: Build
45-
run: pnpm run build
46-
47-
publish:
48-
needs: test
49-
runs-on: ubuntu-latest
50-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
51-
52-
steps:
53-
- name: Checkout code
54-
uses: actions/checkout@v4
55-
56-
- name: Install pnpm
57-
uses: pnpm/action-setup@v4
58-
with:
59-
version: latest
60-
61-
- name: Setup Node.js
62-
uses: actions/setup-node@v4
63-
with:
64-
node-version: 20
65-
registry-url: 'https://registry.npmjs.org'
66-
cache: 'pnpm'
67-
68-
- name: Install dependencies
69-
run: pnpm install --frozen-lockfile
70-
71-
- name: Build and test
72-
run: pnpm run prepublishOnly
73-
74-
- name: Publish to npm
75-
run: pnpm publish --no-git-checks
76-
env:
77-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
78-
if: "!contains(github.event.head_commit.message, '[skip publish]')"
45+
run: pnpm run build

.github/workflows/publish.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Publish to NPM
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version-bump:
7+
description: 'Version bump type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
skip-tests:
16+
description: 'Skip running tests before publish'
17+
required: false
18+
default: false
19+
type: boolean
20+
21+
jobs:
22+
publish:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v4
28+
with:
29+
# Fetch full history for version bumping
30+
fetch-depth: 0
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Install pnpm
34+
uses: pnpm/action-setup@v4
35+
with:
36+
version: latest
37+
38+
- name: Setup Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: 20
42+
registry-url: 'https://registry.npmjs.org'
43+
cache: 'pnpm'
44+
45+
- name: Install dependencies
46+
run: pnpm install --frozen-lockfile
47+
48+
- name: Run full test suite (unless skipped)
49+
if: ${{ !inputs.skip-tests }}
50+
run: pnpm run prepublishOnly
51+
52+
- name: Build only (if tests skipped)
53+
if: ${{ inputs.skip-tests }}
54+
run: pnpm run build
55+
56+
- name: Configure git
57+
run: |
58+
git config --local user.email "action@github.com"
59+
git config --local user.name "GitHub Action"
60+
61+
- name: Bump version
62+
run: |
63+
pnpm version ${{ inputs.version-bump }} --no-git-tag-version
64+
echo "NEW_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
65+
66+
- name: Update package.json and create commit
67+
run: |
68+
git add package.json
69+
git commit -m "chore: bump version to v${{ env.NEW_VERSION }} [skip ci]"
70+
git tag "v${{ env.NEW_VERSION }}"
71+
72+
- name: Push changes and tags
73+
run: |
74+
git push origin main
75+
git push origin "v${{ env.NEW_VERSION }}"
76+
77+
- name: Publish to npm
78+
run: pnpm publish --access public --no-git-checks
79+
env:
80+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
81+
82+
- name: Create GitHub Release
83+
uses: actions/create-release@v1
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
with:
87+
tag_name: "v${{ env.NEW_VERSION }}"
88+
release_name: "Release v${{ env.NEW_VERSION }}"
89+
draft: false
90+
prerelease: false
91+
body: |
92+
## Changes in v${{ env.NEW_VERSION }}
93+
94+
This release was created automatically from the main branch.
95+
96+
### Installation
97+
```bash
98+
npm install zonr@${{ env.NEW_VERSION }}
99+
# or
100+
pnpm add zonr@${{ env.NEW_VERSION }}
101+
```
102+
103+
See [CHANGELOG.md](CHANGELOG.md) for detailed changes.

0 commit comments

Comments
 (0)