Skip to content

Commit daba30f

Browse files
Yukaiicursoragent
andcommitted
Add develop branch npm prerelease publishing
Publish beta-tagged builds on develop pushes while keeping stable releases on version tags. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 841daa6 commit daba30f

1 file changed

Lines changed: 74 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
branches:
8+
- develop
79

810
permissions:
911
id-token: write # Required for OIDC
10-
contents: read
12+
contents: write # Required for GitHub pre-releases
1113

1214
jobs:
13-
publish:
14-
name: Publish to npm
15+
publish-release:
16+
name: Release (tag)
17+
if: startsWith(github.ref, 'refs/tags/v')
1518
runs-on: ubuntu-latest
1619

1720
steps:
@@ -40,4 +43,71 @@ jobs:
4043
run: pnpm run test
4144

4245
- name: Publish to npm
43-
run: npm publish
46+
run: npm publish --access public
47+
48+
publish-prerelease:
49+
name: Pre-release (develop)
50+
if: github.ref == 'refs/heads/develop'
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v4
56+
with:
57+
fetch-depth: 0
58+
59+
- name: Setup pnpm
60+
uses: pnpm/action-setup@v4
61+
with:
62+
version: 10.28.0
63+
64+
- name: Use Node.js 24
65+
uses: actions/setup-node@v4
66+
with:
67+
node-version: '24'
68+
registry-url: 'https://registry.npmjs.org'
69+
cache: 'pnpm'
70+
71+
- name: Install dependencies
72+
run: pnpm install --frozen-lockfile
73+
74+
- name: Configure Git
75+
run: |
76+
git config --global user.name "github-actions[bot]"
77+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
78+
79+
- name: Generate pre-release version
80+
run: |
81+
CURRENT_VERSION=$(node -p "require('./package.json').version")
82+
SHORT_SHA=$(git rev-parse --short HEAD)
83+
TIMESTAMP=$(date +%Y%m%d%H%M%S)
84+
PRE_RELEASE_VERSION="${CURRENT_VERSION}-beta.${TIMESTAMP}.${SHORT_SHA}"
85+
echo "Pre-release version: $PRE_RELEASE_VERSION"
86+
echo "PRE_RELEASE_VERSION=$PRE_RELEASE_VERSION" >> "$GITHUB_ENV"
87+
npm version "$PRE_RELEASE_VERSION" --no-git-tag-version
88+
89+
- name: Build project
90+
run: pnpm run build
91+
92+
- name: Run tests
93+
run: pnpm run test
94+
95+
- name: Publish pre-release to npm
96+
run: npm publish --tag beta --access public
97+
98+
- name: Create GitHub pre-release
99+
env:
100+
GH_TOKEN: ${{ github.token }}
101+
run: |
102+
gh release create "v${PRE_RELEASE_VERSION}" \
103+
--title "Pre-release v${PRE_RELEASE_VERSION}" \
104+
--notes "Pre-release from develop branch.
105+
106+
- Commit: ${{ github.sha }}
107+
- Branch: ${{ github.ref_name }}
108+
109+
Install with:
110+
\`\`\`bash
111+
npm install -g @hackmd/hackmd-cli@beta
112+
\`\`\`" \
113+
--prerelease

0 commit comments

Comments
 (0)