-
Notifications
You must be signed in to change notification settings - Fork 14
76 lines (67 loc) · 2.5 KB
/
Copy pathrelease-patch.yml
File metadata and controls
76 lines (67 loc) · 2.5 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
name: Release Patch
on:
workflow_dispatch:
inputs:
description:
description: 'Release notes (markdown supported)'
required: true
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Bump patch version
id: version
run: |
CURRENT=$(node -p "require('./packages/cli/package.json').version")
IFS='.' read -r major minor patch <<< "$CURRENT"
NEW="${major}.${minor}.$((patch + 1))"
echo "version=${NEW}" >> $GITHUB_OUTPUT
echo "Bumping ${CURRENT} → ${NEW}"
node -e "
const fs = require('fs');
['packages/core/package.json', 'packages/cli/package.json'].forEach(f => {
const pkg = JSON.parse(fs.readFileSync(f, 'utf-8'));
pkg.version = '${NEW}';
fs.writeFileSync(f, JSON.stringify(pkg, null, 2) + '\n');
});
"
- name: Update CHANGELOG
env:
DESCRIPTION: ${{ github.event.inputs.description }}
VERSION: ${{ steps.version.outputs.version }}
run: |
node -e "
const fs = require('fs');
const date = new Date().toISOString().slice(0, 10);
const version = process.env.VERSION;
const description = process.env.DESCRIPTION;
const entry = '## [' + version + '] - ' + date + '\n\n' + description + '\n\n---\n\n';
const changelog = fs.readFileSync('CHANGELOG.md', 'utf-8');
const updated = changelog.replace(/^(# Changelog\n)/, '\$1\n' + entry);
fs.writeFileSync('CHANGELOG.md', updated);
"
- name: Commit, tag and push
run: |
VERSION=${{ steps.version.outputs.version }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add packages/core/package.json packages/cli/package.json CHANGELOG.md
git commit -m "chore: bump version to ${VERSION}"
git tag -a "v${VERSION}" -m "v${VERSION}"
git push origin main
git push origin "v${VERSION}"