Skip to content

Commit 202cf0e

Browse files
committed
[release] Fix release to actually bump on release commit message
1 parent b3a8898 commit 202cf0e

File tree

2 files changed

+65
-9
lines changed

2 files changed

+65
-9
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,29 @@ jobs:
9191
node-version: 20
9292
registry-url: https://registry.npmjs.org
9393

94+
- name: Detect [release] in commit message
95+
id: commit_release
96+
if: github.event_name == 'push'
97+
run: |
98+
msg="$(git log -1 --format=%B)"
99+
is_release=false
100+
bump_type=""
101+
if echo "$msg" | grep -qiF '[release:major]'; then
102+
is_release=true
103+
bump_type=major
104+
elif echo "$msg" | grep -qiF '[release]'; then
105+
is_release=true
106+
bump_type=minor
107+
fi
108+
echo "is_release=$is_release" >> "$GITHUB_OUTPUT"
109+
echo "bump_type=$bump_type" >> "$GITHUB_OUTPUT"
110+
111+
- name: Bump versions ([release])
112+
if: steps.commit_release.outputs.is_release == 'true'
113+
run: node scripts/ci/bump-versions.js
114+
env:
115+
BUMP_TYPE: ${{ steps.commit_release.outputs.bump_type }}
116+
94117
- name: Verify workspace packages
95118
run: |
96119
for dir in packages/appwrite-utils packages/appwrite-utils-helpers packages/appwrite-utils-cli packages/appwrite-utils-mcp; do
@@ -125,31 +148,31 @@ jobs:
125148
run: bash scripts/ci/check-publish.sh packages/appwrite-utils appwrite-utils
126149
env:
127150
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
128-
FORCE_PUBLISH: ${{ steps.manual.outputs.force }}
151+
FORCE_PUBLISH: ${{ steps.commit_release.outputs.is_release == 'true' && 'true' || steps.manual.outputs.force }}
129152

130153
- name: Check appwrite-utils-helpers publish
131154
id: check_helpers
132155
if: github.event_name != 'workflow_dispatch' || steps.manual.outputs.packages == 'all' || contains(steps.manual.outputs.packages, 'appwrite-utils-helpers')
133156
run: bash scripts/ci/check-publish.sh packages/appwrite-utils-helpers appwrite-utils-helpers
134157
env:
135158
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
136-
FORCE_PUBLISH: ${{ steps.manual.outputs.force }}
159+
FORCE_PUBLISH: ${{ steps.commit_release.outputs.is_release == 'true' && 'true' || steps.manual.outputs.force }}
137160

138161
- name: Check appwrite-utils-cli publish
139162
id: check_cli
140163
if: github.event_name != 'workflow_dispatch' || steps.manual.outputs.packages == 'all' || contains(steps.manual.outputs.packages, 'appwrite-utils-cli')
141164
run: bash scripts/ci/check-publish.sh packages/appwrite-utils-cli appwrite-utils-cli
142165
env:
143166
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
144-
FORCE_PUBLISH: ${{ steps.manual.outputs.force }}
167+
FORCE_PUBLISH: ${{ steps.commit_release.outputs.is_release == 'true' && 'true' || steps.manual.outputs.force }}
145168

146169
- name: Check appwrite-utils-mcp publish
147170
id: check_mcp
148171
if: github.event_name != 'workflow_dispatch' || steps.manual.outputs.packages == 'all' || contains(steps.manual.outputs.packages, 'appwrite-utils-mcp')
149172
run: bash scripts/ci/check-publish.sh packages/appwrite-utils-mcp appwrite-utils-mcp
150173
env:
151174
GITHUB_EVENT_BEFORE: ${{ github.event.before }}
152-
FORCE_PUBLISH: ${{ steps.manual.outputs.force }}
175+
FORCE_PUBLISH: ${{ steps.commit_release.outputs.is_release == 'true' && 'true' || steps.manual.outputs.force }}
153176

154177
- name: Build appwrite-utils
155178
if: github.event_name != 'workflow_dispatch' || steps.manual.outputs.packages == 'all' || contains(steps.manual.outputs.packages, 'appwrite-utils')
@@ -173,7 +196,7 @@ jobs:
173196
steps.check_helpers.outputs.should_publish == 'true' ||
174197
steps.check_cli.outputs.should_publish == 'true' ||
175198
steps.check_mcp.outputs.should_publish == 'true') &&
176-
(github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
199+
(steps.commit_release.outputs.is_release == 'true' || github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
177200
run: |
178201
publish_packages=""
179202
if [[ "${{ steps.check_utils.outputs.should_publish }}" == "true" ]]; then
@@ -195,28 +218,28 @@ jobs:
195218
PUBLISH_PACKAGES="$publish_packages" node scripts/ci/prepare-publish.js
196219
197220
- name: Publish appwrite-utils-helpers
198-
if: steps.check_helpers.outputs.should_publish == 'true' && (github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
221+
if: steps.check_helpers.outputs.should_publish == 'true' && (steps.commit_release.outputs.is_release == 'true' || github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
199222
run: npm publish --access public
200223
working-directory: packages/appwrite-utils-helpers
201224
env:
202225
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
203226

204227
- name: Publish appwrite-utils
205-
if: steps.check_utils.outputs.should_publish == 'true' && (github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
228+
if: steps.check_utils.outputs.should_publish == 'true' && (steps.commit_release.outputs.is_release == 'true' || github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
206229
run: npm publish --access public
207230
working-directory: packages/appwrite-utils
208231
env:
209232
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
210233

211234
- name: Publish appwrite-utils-cli
212-
if: steps.check_cli.outputs.should_publish == 'true' && (github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
235+
if: steps.check_cli.outputs.should_publish == 'true' && (steps.commit_release.outputs.is_release == 'true' || github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
213236
run: npm publish --access public
214237
working-directory: packages/appwrite-utils-cli
215238
env:
216239
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
217240

218241
- name: Publish appwrite-utils-mcp
219-
if: steps.check_mcp.outputs.should_publish == 'true' && (github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
242+
if: steps.check_mcp.outputs.should_publish == 'true' && (steps.commit_release.outputs.is_release == 'true' || github.event_name != 'workflow_dispatch' || steps.manual.outputs.publish == 'true')
220243
run: npm publish --access public
221244
working-directory: packages/appwrite-utils-mcp
222245
env:

scripts/ci/bump-versions.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import fs from "fs";
2+
import path from "path";
3+
4+
const root = process.cwd();
5+
const bumpType = (process.env.BUMP_TYPE || "minor").toLowerCase();
6+
7+
if (bumpType !== "minor" && bumpType !== "major") {
8+
console.error(`Invalid BUMP_TYPE: ${bumpType}. Must be "minor" or "major".`);
9+
process.exit(1);
10+
}
11+
12+
const packages = [
13+
"packages/appwrite-utils/package.json",
14+
"packages/appwrite-utils-helpers/package.json",
15+
"packages/appwrite-utils-cli/package.json",
16+
"packages/appwrite-utils-mcp/package.json",
17+
];
18+
19+
for (const rel of packages) {
20+
const filePath = path.join(root, rel);
21+
const pkg = JSON.parse(fs.readFileSync(filePath, "utf8"));
22+
const [major, minor, patch] = pkg.version.split(".").map(Number);
23+
24+
const oldVersion = pkg.version;
25+
if (bumpType === "major") {
26+
pkg.version = `${major + 1}.0.0`;
27+
} else {
28+
pkg.version = `${major}.${minor + 1}.0`;
29+
}
30+
31+
fs.writeFileSync(filePath, JSON.stringify(pkg, null, 2) + "\n");
32+
console.log(`${pkg.name}: ${oldVersion} -> ${pkg.version}`);
33+
}

0 commit comments

Comments
 (0)