-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (49 loc) · 1.97 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: release
on:
release:
types: [published]
jobs:
release:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.19"
check-latest: true
cache: true
- name: Build binaries
run: |
export VERSION=$(git describe --tags)
export CGO_ENABLED=0
export LDFLAGS="-X 'main.Version=${VERSION}'"
export GOOS=linux GOARCH=amd64 && go build -v -o "owh-${VERSION}-${GOOS}-${GOARCH}" -ldflags "${LDFLAGS}"
export GOOS=linux GOARCH=arm GOARM=6 && go build -o "owh-${VERSION}-${GOOS}-${GOARCH}" -ldflags "${LDFLAGS}"
export GOOS=linux GOARCH=arm64 && go build -o "owh-${VERSION}-${GOOS}-${GOARCH}" -ldflags "${LDFLAGS}"
export GOOS=darwin GOARCH=amd64 && go build -o "owh-${VERSION}-${GOOS}-${GOARCH}" -ldflags "${LDFLAGS}"
export GOOS=windows GOARCH=amd64 && go build -o "owh-${VERSION}-${GOOS}-${GOARCH}.exe" -ldflags "${LDFLAGS}"
- name: Upload release artifacts
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require("fs").promises;
const { repo: { owner, repo }, sha } = context;
const release = await github.rest.repos.getReleaseByTag({
owner, repo,
tag: process.env.GITHUB_REF.replace("refs/tags/", ""),
});
console.log("Release:", { release });
for (let file of await fs.readdir(".")) {
if (!file.startsWith("owh-")) continue;
console.log("Uploading", file);
await github.rest.repos.uploadReleaseAsset({
owner, repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(file),
});
}