Skip to content

Continue uploading releases #14

Continue uploading releases

Continue uploading releases #14

name: Initialize releases
on: [push]
jobs:
initialize:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: mirror Git for Windows' Pacman repository to GitHub releases
uses: actions/github-script@v7
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const makeList = require('./make-list.js')
const list = makeList()
const ChildProcess = require('child_process')
const run = (cmd, args) => {
const { error, status, stderr, stdout } = ChildProcess.spawnSync(cmd, args, { stdio: 'inherit' })
if (error) {
throw error
}
if (status !== 0) {
throw new Error(`${cmd} ${args.join(' ')} exited with status ${status} (stderr: ${stderr})`)
}
return stdout
}
let startAt = '2022-07-13T10:40:15.000Z'
const baseURL = 'https://wingit.blob.core.windows.net/'
for (const release of list) {
console.log(JSON.stringify(release, null, 2))
if (startAt) {
if ((new Date(release.date)).toISOString() === startAt) {
startAt = null
} else {
console.log(`skipping ${(new Date(release.date)).toISOString()}`)
continue
}
}
const targets = []
for (name of release.names) {
const target = name.replace(/.*\//, '')
console.log(`downloading ${baseURL}${name} to ${target}`)
// call on curl to download the file
run('curl', ['-sfLo', target, `${baseURL}${name}`])
targets.push(target)
}
console.log(`creating release ${release.date}`)
// call GitHub CLI to upload the files to a new release
run('gh', [
'release',
'create',
'-R',
'${{ github.repository }}',
'--title',
(new Date(release.date)).toString(),
(new Date(release.date)).toISOString().replace(/:/g, '-'),
...targets])
}