summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Medvedev <anton@medv.io>2025-12-01 22:14:25 +0100
committerAnton Medvedev <anton@medv.io>2025-12-01 22:14:25 +0100
commitb5d9de56e3572bbfe67f1081da7fc19277b1cb48 (patch)
tree4d1eaecc1ea0bda4fed906857a0edd9ae3eedecc
parent2630f5dd20d9427f958f6f692bcbb92ad258f01b (diff)
Add build script for releases
-rw-r--r--.github/scripts/build.mjs33
1 files changed, 33 insertions, 0 deletions
diff --git a/.github/scripts/build.mjs b/.github/scripts/build.mjs
new file mode 100644
index 0000000..251a036
--- /dev/null
+++ b/.github/scripts/build.mjs
@@ -0,0 +1,33 @@
+$.verbose = true
+
+const goos = [
+ 'linux',
+ 'darwin',
+ 'windows',
+]
+const goarch = [
+ 'amd64',
+ 'arm64',
+]
+
+const name = (GOOS, GOARCH) => `gitmal_${GOOS}_${GOARCH}` + (GOOS === 'windows' ? '.exe' : '')
+
+const resp = await fetch('https://api.github.com/repos/antonmedv/gitmal/releases/latest')
+const {tag_name: latest} = await resp.json()
+
+await $`go mod download`
+
+await Promise.all(
+ goos.flatMap(GOOS =>
+ goarch.map(GOARCH =>
+ $`GOOS=${GOOS} GOARCH=${GOARCH} go build -o ${name(GOOS, GOARCH)}`)))
+
+await Promise.all(
+ goos.flatMap(GOOS =>
+ goarch.map(GOARCH =>
+ $`gh release upload ${latest} ${name(GOOS, GOARCH)}`)))
+
+await Promise.all(
+ goos.flatMap(GOOS =>
+ goarch.map(GOARCH =>
+ $`rm ${name(GOOS, GOARCH)}`)))