Skip to content

Commit c3b5db6

Browse files
authored
Merge branch 'main' into feat/db-migrations
2 parents 3f0ccab + 2f6bd7c commit c3b5db6

4 files changed

Lines changed: 64 additions & 33 deletions

File tree

.github/workflows/version-bump.yml

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,35 +68,69 @@ jobs:
6868
exit 1
6969
fi
7070
71-
- name: Bump root package
71+
- name: Bump package versions
7272
env:
7373
VERSION: ${{ steps.version.outputs.version }}
74-
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
75-
76-
- name: Bump git-proxy-cli package
77-
working-directory: packages/git-proxy-cli
78-
env:
79-
VERSION: ${{ steps.version.outputs.version }}
80-
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
74+
run: |
75+
npm pkg set "version=$VERSION"
76+
npm pkg set "version=$VERSION" --workspace @finos/git-proxy-cli
77+
npm pkg set "dependencies.@finos/git-proxy=$VERSION" --workspace @finos/git-proxy-cli
8178
82-
- name: Sync git-proxy-cli's pin on the root package
79+
- name: Patch lockfile versions
8380
env:
8481
VERSION: ${{ steps.version.outputs.version }}
8582
run: |
8683
node -e '
8784
const fs = require("fs");
88-
const p = "packages/git-proxy-cli/package.json";
89-
const pkg = JSON.parse(fs.readFileSync(p, "utf8"));
90-
if (!pkg.dependencies || !pkg.dependencies["@finos/git-proxy"]) {
91-
console.error("::error::Expected @finos/git-proxy in git-proxy-cli dependencies.");
92-
process.exit(1);
85+
const VERSION = process.env.VERSION;
86+
const ROOT = "@finos/git-proxy";
87+
const CLI_PATH = "packages/git-proxy-cli";
88+
const LOCK = "package-lock.json";
89+
const fail = (m) => { console.error("::error::" + m); process.exit(1); };
90+
91+
const lock = JSON.parse(fs.readFileSync(LOCK, "utf8"));
92+
if (lock.lockfileVersion !== 3) fail("Expected lockfileVersion 3, got " + lock.lockfileVersion + ".");
93+
94+
const rootEntry = lock.packages[""];
95+
const cliEntry = lock.packages[CLI_PATH];
96+
if (!rootEntry) fail("Lockfile has no root package entry.");
97+
if (!cliEntry) fail("Lockfile has no \"" + CLI_PATH + "\" entry.");
98+
if (!(lock.packages["node_modules/" + ROOT] || {}).link) {
99+
fail("Lockfile is missing the workspace link entry for " + ROOT + ". Something has already re-resolved the tree.");
93100
}
94-
pkg.dependencies["@finos/git-proxy"] = process.env.VERSION;
95-
fs.writeFileSync(p, JSON.stringify(pkg, null, 2) + "\n");
101+
if (!cliEntry.dependencies || cliEntry.dependencies[ROOT] === undefined) {
102+
fail(CLI_PATH + " no longer pins " + ROOT + "; this workflow needs updating.");
103+
}
104+
105+
lock.version = VERSION;
106+
rootEntry.version = VERSION;
107+
cliEntry.version = VERSION;
108+
cliEntry.dependencies[ROOT] = VERSION;
109+
110+
fs.writeFileSync(LOCK, JSON.stringify(lock, null, 2) + "\n");
111+
console.log("Patched " + LOCK + " to " + VERSION + ".");
96112
'
97113
98-
- name: Refresh the lockfile
99-
run: npm install --package-lock-only --no-audit --no-fund
114+
- name: Guard against unexpected changes
115+
run: |
116+
UNEXPECTED=$(git diff --name-only | grep -vE '^(package\.json|package-lock\.json|packages/git-proxy-cli/package\.json)$' || true)
117+
if [ -n "$UNEXPECTED" ]; then
118+
echo "::error::A version bump modified files it shouldn't have:"
119+
echo "$UNEXPECTED"
120+
exit 1
121+
fi
122+
123+
CHANGED=$(git diff --numstat -- package-lock.json | awk '{print $1 + $2}')
124+
CHANGED=${CHANGED:-0}
125+
echo "package-lock.json changed lines: $CHANGED"
126+
if [ "$CHANGED" -gt 12 ]; then
127+
echo "::error::package-lock.json changed $CHANGED lines; a version bump should touch eight. Refusing to open the PR."
128+
git --no-pager diff --stat -- package-lock.json
129+
git --no-pager diff -- package-lock.json | head -n 120
130+
exit 1
131+
fi
132+
133+
git --no-pager diff -- package.json package-lock.json packages/git-proxy-cli/package.json
100134
101135
- name: Open version bump PR
102136
env:
@@ -105,7 +139,7 @@ jobs:
105139
MILESTONE_TITLE: ${{ github.event.milestone.title }}
106140
MILESTONE_URL: ${{ github.event.milestone.html_url }}
107141
run: |
108-
BRANCH="chore/bump-version-$VERSION"
142+
BRANCH="chore/bump-version-$VERSION-$GITHUB_RUN_ID"
109143
RELEASE_BRANCH="release/${VERSION%.*}"
110144
111145
git config user.name "github-actions[bot]"
@@ -114,18 +148,15 @@ jobs:
114148
git checkout -b "$BRANCH"
115149
git add package.json package-lock.json packages/git-proxy-cli/package.json
116150
git commit -m "chore: bump git-proxy and git-proxy-cli to $VERSION"
117-
git push -u origin "$BRANCH" --force-with-lease
151+
git push -u origin "$BRANCH"
118152
119153
if [ -n "$MILESTONE_URL" ]; then
120154
SOURCE_LINE="Triggered by closing milestone **$MILESTONE_TITLE** ($MILESTONE_URL)."
121155
else
122156
SOURCE_LINE="Triggered manually for version $VERSION."
123157
fi
124158
125-
BODY=$(printf '%s\n\nBumps:\n- `package.json`, `package-lock.json`\n- `packages/git-proxy-cli/package.json` (including its pin on `@finos/git-proxy`)\n\nOnce merged, cut `%s` from `main` per our [release process](https://git-proxy.finos.org/docs/development/releases) in order to generate a GitHub draft release.\n' "$SOURCE_LINE" "$RELEASE_BRANCH")
159+
BODY=$(printf '%s\n\nBumps:\n- `package.json`, `package-lock.json`\n- `packages/git-proxy-cli/package.json`, including its pin on `@finos/git-proxy`\n\nOnce merged, cut `%s` from `main` per our [release process](https://git-proxy.finos.org/docs/development/releases) in order to generate a GitHub draft release.\n' "$SOURCE_LINE" "$RELEASE_BRANCH")
126160
127-
if gh pr view "$BRANCH" >/dev/null 2>&1; then
128-
echo "PR for $BRANCH already exists. Branch updated, no new PR opened."
129-
else
130-
gh pr create --base main --head "$BRANCH" --title "chore: bump version to $VERSION" --body "$BODY"
131-
fi
161+
gh pr create --base main --head "$BRANCH" \
162+
--title "chore: bump version to $VERSION" --body "$BODY"

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@finos/git-proxy",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Deploy custom push protections and policies on top of Git.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

packages/git-proxy-cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@finos/git-proxy-cli",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Command line interface tool for FINOS GitProxy.",
55
"bin": {
66
"git-proxy-cli": "./dist/index.js"
77
},
88
"dependencies": {
9-
"@finos/git-proxy": "2.0.0"
9+
"@finos/git-proxy": "2.1.0"
1010
},
1111
"scripts": {
1212
"build": "tsc",

0 commit comments

Comments
 (0)