-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (145 loc) · 4.59 KB
/
Copy pathmanual-release.yml
File metadata and controls
163 lines (145 loc) · 4.59 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
name: Manual Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 0.3.16)'
required: true
type: string
create_tag:
description: 'Create git tag'
required: false
default: true
type: boolean
publish_npm:
description: 'Publish to NPM'
required: false
default: true
type: boolean
publish_jsr:
description: 'Publish to JSR'
required: false
default: true
type: boolean
jobs:
manual-release:
name: Manual Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # Required for JSR OIDC authentication
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Update version in package.json
run: |
echo "Updating version to ${{ inputs.version }}"
npm version ${{ inputs.version }} --no-git-tag-version
- name: Build and test
run: |
npm run build
npm run test:ci
- name: Create package
run: npm pack
- name: Commit version update
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add package.json package-lock.json jsr.json
git commit -m "chore: bump version to ${{ inputs.version }}"
git push
- name: Create and push tag
if: inputs.create_tag == true
run: |
git tag v${{ inputs.version }}
git push origin v${{ inputs.version }}
- name: Update JSR version
if: inputs.publish_jsr == true
run: |
if [ -f "jsr.json" ]; then
echo "Updating JSR version to ${{ inputs.version }}"
node -e "
const jsr = require('./jsr.json');
jsr.version = '${{ inputs.version }}';
require('fs').writeFileSync('jsr.json', JSON.stringify(jsr, null, 2));
"
git add jsr.json
if git diff --cached --quiet; then
echo "JSR version already aligned with package.json"
else
git commit --amend --no-edit
git push --force-with-lease
fi
fi
- name: Publish to NPM
if: inputs.publish_npm == true
run: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
npm publish --access public
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to JSR
if: inputs.publish_jsr == true
run: |
git status --short
npx jsr publish
- name: Generate changelog
id: release_notes
run: |
NOTES="$RUNNER_TEMP/release_notes.md"
{
echo "## 🎉 SomonScript v${{ inputs.version }}";
echo "";
echo "### ✨ What's New";
echo "";
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "");
if [ -n "$LAST_TAG" ]; then
echo "Changes since $LAST_TAG:";
git log --pretty=format:"- %s" "$LAST_TAG"..HEAD^;
else
echo "- Manual release v${{ inputs.version }}";
fi
echo "";
echo "### 📦 Installation";
echo '```bash';
echo 'npm install -g @lindentech/somon-script';
echo '```';
} > "$NOTES"
echo "path=$NOTES" >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ inputs.version }}
name: "SomonScript v${{ inputs.version }}"
body_path: ${{ steps.release_notes.outputs.path }}
files: |
*.tgz
draft: false
prerelease: false
- name: Summary
run: |
echo "🎉 Manual Release v${{ inputs.version }} completed!"
echo "✅ Version metadata committed"
echo "✅ Git tag created: v${{ inputs.version }}"
echo "✅ GitHub release created"
if [ "${{ inputs.publish_npm }}" == "true" ]; then
echo "✅ NPM package published"
else
echo "⏸️ NPM publish skipped"
fi
if [ "${{ inputs.publish_jsr }}" == "true" ]; then
echo "✅ JSR package published"
else
echo "⏸️ JSR publish skipped"
fi