Skip to content

Commit 56f8d30

Browse files
committed
Add a workflow to initialize the releases
Git for Windows' Pacman repository is too opaque. Let's first mirror it to GitHub releases at https://github.com/git-for-windows/pacman-repo. The idea is to eventually switch completely to that transparent process of uploading new packages to GitHub releases in that repository. And after that, updating its x86_64, aarch64 and i686 branches (representing Git for Windows' new Pacman repository) to reflect the updated packages. Since GitHub Actions' debugging facilities are totally insufficient, let's first try this with the initial release and then stop. In the unlikely event that it works, I will then proceed to handle the remaining releases. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e6d16d4 commit 56f8d30

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Initialize releases
2+
3+
on: [push]
4+
5+
jobs:
6+
initialize:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: mirror Git for Windows' Pacman repository to GitHub releases
13+
uses: actions/github-script@v7
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
script: |
18+
const makeList = require('./make-list.js')
19+
const list = makeList()
20+
21+
const ChildProcess = require('child_process')
22+
const run = (cmd, args) => {
23+
const { error, status, stderr, stdout } = ChildProcess.spawnSync(cmd, args, { stdio: 'inherit' })
24+
if (error) {
25+
throw error
26+
}
27+
if (status !== 0) {
28+
throw new Error(`${cmd} ${args.join(' ')} exited with status ${status} (stderr: ${stderr})`)
29+
}
30+
return stdout
31+
}
32+
33+
let startAfter = 'Mon Feb 05 2018 23:28:59 GMT+0000 (Coordinated Universal Time)'
34+
const baseURL = 'https://wingit.blob.core.windows.net/'
35+
for (const release of list) {
36+
if (startAfter) {
37+
if (`${release.date}` === startAfter) {
38+
startAfter = null
39+
} else {
40+
console.log(`skipping ${release.date}`)
41+
continue
42+
}
43+
}
44+
45+
console.log(JSON.stringify(release, null, 2))
46+
const targets = []
47+
for (name of release.names) {
48+
const target = name.replace(/.*\//, '')
49+
console.log(`downloading ${baseURL}${name} to ${target}`)
50+
// call on curl to download the file
51+
run('curl', ['-sfLo', target, `${baseURL}${name}`])
52+
targets.push(target)
53+
}
54+
55+
console.log(`creating release ${release.date}`)
56+
// call GitHub CLI to upload the files to a new release
57+
run('gh', [
58+
'release',
59+
'create',
60+
'-R',
61+
'${{ github.repository }}',
62+
'--title',
63+
(new Date(release.date)).toString(),
64+
(new Date(release.date)).toISOString().replace(/:/g, '-'),
65+
...targets])
66+
break
67+
}
68+

0 commit comments

Comments
 (0)