Skip to content

Commit ee58e3b

Browse files
committed
refactor: move platform version sync into simple-release config
Override NpmProject.bump() to sync optionalDependencies after version bump, removing the need for a separate workflow step.
1 parent 4ad0480 commit ee58e3b

2 files changed

Lines changed: 28 additions & 28 deletions

File tree

.github/workflows/release.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -83,33 +83,6 @@ jobs:
8383
workflow: pull-request
8484
github-token: ${{ github.token }}
8585
branch: release
86-
- name: Sync optional dependency versions on release branch
87-
run: |
88-
git fetch origin release || exit 0
89-
git checkout release
90-
VERSION=$(node -p "require('./package.json').version")
91-
node -e "
92-
const fs = require('fs');
93-
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
94-
let changed = false;
95-
for (const dep of Object.keys(pkg.optionalDependencies || {})) {
96-
if (pkg.optionalDependencies[dep] !== pkg.version) {
97-
pkg.optionalDependencies[dep] = pkg.version;
98-
changed = true;
99-
}
100-
}
101-
if (changed) {
102-
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
103-
process.stdout.write('updated');
104-
} else {
105-
process.stdout.write('unchanged');
106-
}
107-
"
108-
if ! git diff --quiet package.json 2>/dev/null; then
109-
git add package.json
110-
git commit -m "chore: sync platform package versions to $VERSION"
111-
git push origin release
112-
fi
11386
validate-release-pr:
11487
name: Validate release PR
11588
needs: pull-request

.simple-release.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
import { readFileSync, writeFileSync } from "node:fs";
12
import { NpmProject } from "@simple-release/npm";
23

3-
export const project = new NpmProject();
4+
class ArchgateProject extends NpmProject {
5+
async bump(options) {
6+
const result = await super.bump(options);
7+
8+
if (result) {
9+
const pkgPath = "package.json";
10+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
11+
const version = pkg.version;
12+
let changed = false;
13+
14+
for (const dep of Object.keys(pkg.optionalDependencies || {})) {
15+
if (pkg.optionalDependencies[dep] !== version) {
16+
pkg.optionalDependencies[dep] = version;
17+
changed = true;
18+
}
19+
}
20+
21+
if (changed) {
22+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
23+
}
24+
}
25+
26+
return result;
27+
}
28+
}
29+
30+
export const project = new ArchgateProject();

0 commit comments

Comments
 (0)