Repository navigation
131 lines (108 loc) · 3.63 KB
/
Copy pathpublish.yml
File metadata and controls
131 lines (108 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Publish to NPM
on:
push:
tags:
- 'v*'
branches:
- develop
permissions:
id-token: write # OIDC for npm trusted publishing
contents: write # draft / pre-releases via gh
jobs:
publish-release:
name: Release (tag)
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 10.33.2
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
cache-dependency-path: nodejs/pnpm-lock.yaml
- name: Install dependencies
working-directory: nodejs
run: pnpm install --frozen-lockfile
- name: Build
working-directory: nodejs
run: pnpm build
- name: Publish to NPM
working-directory: nodejs
run: pnpm publish --access public
- name: Extract version from tag
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Extracted version: $VERSION"
- name: Create draft release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" \
--title "Release v${VERSION}" \
--draft
publish-prerelease:
name: Pre-release (develop)
if: github.ref == 'refs/heads/develop'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v6
with:
version: 10.33.2
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
cache: "pnpm"
cache-dependency-path: nodejs/pnpm-lock.yaml
- name: Install dependencies
working-directory: nodejs
run: pnpm install --frozen-lockfile
- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Generate pre-release version
working-directory: nodejs
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
SHORT_SHA=$(git rev-parse --short HEAD)
TIMESTAMP=$(date +%Y%m%d%H%M%S)
PRE_RELEASE_VERSION="${CURRENT_VERSION}-beta.${TIMESTAMP}.${SHORT_SHA}"
echo "Pre-release version: $PRE_RELEASE_VERSION"
echo "PRE_RELEASE_VERSION=$PRE_RELEASE_VERSION" >> $GITHUB_ENV
pnpm version $PRE_RELEASE_VERSION --no-git-tag-version
- name: Build
working-directory: nodejs
run: pnpm build
- name: Publish pre-release to NPM
working-directory: nodejs
run: pnpm publish --tag beta --access public
- name: Create GitHub pre-release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${PRE_RELEASE_VERSION}" \
--title "Pre-release v${PRE_RELEASE_VERSION}" \
--notes "🚀 **Pre-release from develop branch**
This is an automated pre-release build from the develop branch.
**Changes:**
- Commit: ${{ github.sha }}
- Branch: ${{ github.ref_name }}
**Installation:**
\`\`\`bash
npm install @hackmd/api@beta
\`\`\`
**Note:** This is a pre-release version and may contain unstable features." \
--prerelease