purescript-pg/bun/prepare.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

import { readFile, writeFile } from 'fs/promises'
import { execSync } from 'child_process'
2024-04-03 21:37:27 +00:00
2024-04-03 21:41:53 +00:00
let ver = process.argv[2]
2024-04-03 21:37:27 +00:00
if (!ver) {
console.error(`tag required: bun bun/prepare.js v1.0.0`)
} else if (!/v\d+\.\d+\.\d+/.test(ver)) {
console.error(`invalid tag: ${ver}`)
}
2024-04-03 21:41:53 +00:00
ver = (/\d+\.\d+\.\d+/.exec(ver) || [])[0] || ''
2024-04-03 21:37:27 +00:00
const pkg = await readFile('./package.json', 'utf8')
2024-04-03 21:41:53 +00:00
const pkgnew = pkg.replace(/"version": ".+"/, `"version": "v${ver}"`)
2024-04-03 21:37:27 +00:00
await writeFile('./package.json', pkgnew)
const spago = await readFile('./spago.yaml', 'utf8')
const spagonew = spago.replace(/version: .+/, `version: '${ver}'`)
await writeFile('./spago.yaml', spagonew)
const readme = await readFile('./README.md', 'utf8')
const readmenew = readme.replace(
2024-08-21 02:42:58 +00:00
/\/packages\/purescript-postgresql\/.+?\//g,
`/packages/purescript-postgresql/${ver}/`,
)
2024-04-03 21:37:27 +00:00
await writeFile('./README.md', readmenew)
2024-04-03 21:40:17 +00:00
execSync(`git add spago.yaml package.json README.md`)
2024-04-03 21:42:41 +00:00
execSync(`git commit -m 'chore: prepare v${ver}'`)
execSync(`git tag v${ver}`)
2024-04-03 21:37:27 +00:00
execSync(`git push --tags`)
execSync(`git push --mirror github-mirror`)