Skip to content

Avoid clashes between the database files #25

Avoid clashes between the database files

Avoid clashes between the database files #25

name: Initialize releases
on: [push]
jobs:
initialize:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/create-github-app-token@v1
id: token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: mirror Git for Windows' Pacman repository to GitHub releases
uses: actions/github-script@v7
env:
GH_TOKEN: ${{ steps.token.outputs.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: 'pipe' })
if (error) {
throw error
}
if (status !== 0) {
throw new Error(`${cmd} ${args.join(' ')} exited with status ${status} (stderr: ${stderr}, stdout: ${stdout}, error: ${error}, status: ${status})`)
}
return stdout
}
let startAt = '2025-02-14T08:31:04.000Z'
const baseURL = 'https://wingit.blob.core.windows.net/'
for (const release of list) {
const date = (new Date(release.date)).toISOString()
console.log(`::group::${date}\n${JSON.stringify(release, null, 2)}\n::endgroup::`)
if (startAt) {
if (date === startAt) {
startAt = null
} else {
console.log(`skipping ${date}`)
continue
}
}
const targets = []
for (name of release.names) {
const target = name
.replace(/^(i686|x86_64|aarch64)\/(git-for-windows)\./, '$2-$1.') // avoid filename conflicts
.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])
}