Skip to content

Commit 75af1bb

Browse files
committed
Add GitHub Actions to automatically build release binaries
1 parent 31e302b commit 75af1bb

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/release.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
on:
2+
release:
3+
types: [published]
4+
name: Publish Release Binaries
5+
jobs:
6+
release:
7+
name: Build and Upload Release Binaries
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
steps:
12+
- name: Install Go
13+
uses: actions/setup-go@v2
14+
with:
15+
go-version: 1.x
16+
- name: Checkout repository
17+
uses: actions/checkout@v2
18+
- name: Build binaries
19+
run: |
20+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "snid-${{ github.event.release.name }}-linux-amd64"
21+
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -o "snid-${{ github.event.release.name }}-linux-arm"
22+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o "snid-${{ github.event.release.name }}-linux-arm64"
23+
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -o "snid-${{ github.event.release.name }}-linux-386"
24+
- name: Upload binaries
25+
uses: actions/github-script@v3
26+
with:
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
28+
script: |
29+
const fs = require("fs").promises;
30+
const { repo: { owner, repo }, sha } = context;
31+
32+
for (let filename of await fs.readdir(".")) {
33+
if (filename.startsWith("snid-")) {
34+
console.log("Uploading", filename);
35+
await github.repos.uploadReleaseAsset({
36+
owner, repo,
37+
release_id: ${{ github.event.release.id }},
38+
name: filename,
39+
data: await fs.readFile(filename),
40+
});
41+
}
42+
}

0 commit comments

Comments
 (0)