Skip to content

Commit a494353

Browse files
committed
open-pr: special-case git-lfs
The package definition of `mingw-w64-git-lfs` is a bit more complex than `updpkgsums` can handle. Let's codify the knowledge how to update it, and teach the `open-pr` workflow to use it when updating that particular package. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8dcfb6d commit a494353

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

.github/workflows/open-pr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ jobs:
152152
exit 0
153153
fi &&
154154
155-
updpkgsums &&
155+
update_script="$GITHUB_WORKSPACE/update-scripts/$PACKAGE_TO_UPGRADE"
156+
if test -f "$update_script"
157+
then
158+
$update_script "$UPGRADE_TO_VERSION"
159+
else
160+
updpkgsums
161+
fi &&
156162
msg="$PACKAGE_TO_UPGRADE: update to $UPGRADE_TO_VERSION" &&
157163
git commit -sm "$msg" PKGBUILD &&
158164
echo "msg=$msg" >>$GITHUB_OUTPUT &&

update-scripts/mingw-w64-git-lfs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env node
2+
3+
// The `PKGBUILD` file of `mingw-w64-git-lfs` is a bit complicated, as it has
4+
// separate `case` arms for the different architectures.
5+
6+
// Therefore we need to be a bit more careful when updating than just running
7+
// `updpkgsums`.
8+
9+
(async () => {
10+
const version = process.argv[2]
11+
12+
const githubApiRequest = require('../github-api-request')
13+
const { body: releaseNotes } = await githubApiRequest(
14+
console,
15+
null,
16+
'GET',
17+
`/repos/git-lfs/git-lfs/releases/tags/v${version}`
18+
)
19+
20+
const getSHA256 = (architecture) =>
21+
releaseNotes.match(new RegExp(`git-lfs-windows-${architecture}-\\S+\\.zip.*\r?\n([0-9a-f]{64})\r?\n`))[1]
22+
23+
const fs = require('fs')
24+
let PKGBUILD = fs.readFileSync('PKGBUILD').toString('utf-8')
25+
for (const architecture of [
26+
{ lfs: '386', msys2: 'i686' },
27+
{ lfs: 'amd64', msys2: 'x86_64' },
28+
{ lfs: 'arm64', msys2: 'aarch64' }
29+
]) {
30+
const match = PKGBUILD.match(new RegExp(`^([^]*\\r?\\n${architecture.msys2}\\)[^]*? sha256sum=)[0-9a-f]{64}([^]*)$`))
31+
PKGBUILD = `${match[1]}${getSHA256(architecture.lfs)}${match[2]}`
32+
}
33+
fs.writeFileSync('PKGBUILD', PKGBUILD)
34+
})().catch(console.log)

0 commit comments

Comments
 (0)