-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
217 lines (191 loc) · 8.56 KB
/
release.yml
File metadata and controls
217 lines (191 loc) · 8.56 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: Manual Release
# Fixed: Now properly uses prerelease_tag input for npm publish
# when version_type starts with 'pre'
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to release from'
required: true
default: 'next'
type: string
version_type:
description: 'Version bump type'
required: true
default: 'prerelease'
type: choice
options:
- patch
- minor
- major
- prerelease
- prepatch
- preminor
- premajor
prerelease_tag:
description: 'Prerelease tag (alpha, beta, rc) - only used with prerelease/pre* types'
required: false
default: 'beta'
type: choice
options:
- alpha
- beta
- rc
dry_run:
description: 'Dry run (do not publish)'
required: false
default: false
type: boolean
jobs:
release:
name: Manual Release
runs-on: ubuntu-latest
concurrency:
group: release-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}
cancel-in-progress: false
permissions:
contents: write
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
# Use git token for checkout and pushing
token: ${{ secrets.GIT_TOKEN }}
- name: Setup pnpm
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
- name: Setup Node.js
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
with:
node-version: '24'
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run build
run: pnpm build
- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Version bump (dry run)
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "🧪 Running version bump in dry-run mode..."
if [[ "${{ github.event.inputs.version_type }}" == prerelease* ]]; then
node scripts/version.js ${{ github.event.inputs.version_type }} --prerelease-tag=${{ github.event.inputs.prerelease_tag }} --dry-run
else
node scripts/version.js ${{ github.event.inputs.version_type }} --dry-run
fi
- name: Version bump
if: ${{ github.event.inputs.dry_run != 'true' }}
run: |
echo "🚀 Running version bump..."
if [[ "${{ github.event.inputs.version_type }}" == prerelease* ]]; then
node scripts/version.js ${{ github.event.inputs.version_type }} --prerelease-tag=${{ github.event.inputs.prerelease_tag }}
else
node scripts/version.js ${{ github.event.inputs.version_type }}
fi
# Get the new version tag
NEW_TAG=$(git describe --tags --abbrev=0)
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
# Push changes and tags
git push origin ${{ github.event.inputs.branch }} --tags
- name: Publish packages (dry run)
if: ${{ github.event.inputs.dry_run == 'true' }}
run: |
echo "🧪 Running publish in dry-run mode..."
if [[ "${{ github.event.inputs.version_type }}" == pre* ]]; then
echo "Setting npm tag to: ${{ github.event.inputs.prerelease_tag }}"
pnpm -r publish --dry-run --no-git-checks --tag=${{ github.event.inputs.prerelease_tag }}
else
echo "Setting npm tag to: latest"
pnpm -r publish --dry-run --no-git-checks --tag=latest
fi
- name: Publish packages
if: ${{ github.event.inputs.dry_run != 'true' }}
run: |
echo "📦 Publishing packages..."
if [[ "${{ github.event.inputs.version_type }}" == pre* ]]; then
echo "Setting npm tag to: ${{ github.event.inputs.prerelease_tag }}"
pnpm -r publish --no-git-checks --tag=${{ github.event.inputs.prerelease_tag }}
else
echo "Setting npm tag to: latest"
pnpm -r publish --no-git-checks --tag=latest
fi
- name: Create GitHub Release (draft)
if: ${{ github.event.inputs.dry_run != 'true' }}
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
github-token: ${{ secrets.GIT_TOKEN }}
script: |
const tag = process.env.NEW_TAG;
const versionType = '${{ github.event.inputs.version_type }}';
let releaseBody = `## 🎉 ${versionType.charAt(0).toUpperCase() + versionType.slice(1)} Release\n\n`;
releaseBody += `This release includes ${versionType} version updates for all packages.\n\n`;
releaseBody += `### 📦 Published Packages\n\n`;
// Get package versions from the tag
const fs = require('fs');
const packagesDirs = ['./packages', './tools', './plugins', './tegg/core', './tegg/plugin', './tegg/standalone'];
for (const packagesDir of packagesDirs) {
const packageFolders = fs.readdirSync(packagesDir);
for (const folder of packageFolders) {
const packageJsonPath = `${packagesDir}/${folder}/package.json`;
if (fs.existsSync(packageJsonPath)) {
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
if (packageJson.private) {
continue;
}
releaseBody += `- [${packageJson.name}@${packageJson.version}](https://npmjs.com/package/${packageJson.name}/v/${packageJson.version})\n`;
}
}
}
releaseBody += `\n### 🔄 What's Changed\n\n`;
releaseBody += `<!-- Please add changelog information here manually -->\n`;
releaseBody += `- Add your changelog items here\n`;
releaseBody += `- Remove this placeholder text\n\n`;
releaseBody += `**Full Changelog**: https://github.com/${{ github.repository }}/compare/v${tag}...${tag}`;
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
name: tag,
body: releaseBody,
draft: true,
prerelease: versionType.includes('pre')
});
core.info(`Created draft release: ${release.data.html_url}`);
// Set the release URL as an environment variable for use in summary
core.exportVariable('DRAFT_RELEASE_URL', release.data.html_url);
- name: Sync to cnpm
run: |
node scripts/sync-cnpm.js
- name: Summary
run: |
echo "## 🎉 Release Summary" >> $GITHUB_STEP_SUMMARY
if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then
echo "### 🧪 Dry Run Completed" >> $GITHUB_STEP_SUMMARY
echo "- Version bump: **${{ github.event.inputs.version_type }}**" >> $GITHUB_STEP_SUMMARY
echo "- Branch: **${{ github.event.inputs.branch }}**" >> $GITHUB_STEP_SUMMARY
if [[ "${{ github.event.inputs.version_type }}" == pre* ]]; then
echo "- npm tag: **${{ github.event.inputs.prerelease_tag }}**" >> $GITHUB_STEP_SUMMARY
else
echo "- npm tag: **latest**" >> $GITHUB_STEP_SUMMARY
fi
echo "- Status: **Dry run - no changes made**" >> $GITHUB_STEP_SUMMARY
else
echo "### ✅ Release Completed" >> $GITHUB_STEP_SUMMARY
echo "- Version bump: **${{ github.event.inputs.version_type }}**" >> $GITHUB_STEP_SUMMARY
echo "- Branch: **${{ github.event.inputs.branch }}**" >> $GITHUB_STEP_SUMMARY
echo "- New tag: **$NEW_TAG**" >> $GITHUB_STEP_SUMMARY
if [[ "${{ github.event.inputs.version_type }}" == pre* ]]; then
echo "- npm tag: **${{ github.event.inputs.prerelease_tag }}**" >> $GITHUB_STEP_SUMMARY
else
echo "- npm tag: **latest**" >> $GITHUB_STEP_SUMMARY
fi
echo "- Packages published to npm" >> $GITHUB_STEP_SUMMARY
echo "- Draft GitHub release created: [View Draft Release]($DRAFT_RELEASE_URL)" >> $GITHUB_STEP_SUMMARY
fi