-
Notifications
You must be signed in to change notification settings - Fork 11
45 lines (38 loc) · 2.31 KB
/
project.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
name: Build / Test / Release
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
environment: cicd
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Build
run: |
CGO_ENABLED=0 GOARCH="amd64" GOOS="linux" go build -o dist/webpty_linux_amd64.bin main.go
CGO_ENABLED=0 GOARCH="arm" GOARM=7 GOOS="linux" go build -o dist/webpty_linux_arm.bin main.go
CGO_ENABLED=0 GOOS="darwin" GOARCH="amd64" go build -o dist/webpty_mac_amd64.bin main.go
CGO_ENABLED=0 GOOS="darwin" GOARCH="arm64" go build -o dist/webpty_mac_arm.bin main.go
- name: Test
run: go test ./...
- name: Upload Release Assets
env:
OWNER: mickael-kerjean
REPO: webpty
RELEASE_ID: 79898913
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# remove all assets
curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID/assets" > assets.json
cat assets.json | sed -n 's|^ "id": \([0-9]*\),|\1|p' > existing_assets_ids.txt > asset_ids.txt
cat asset_ids.txt | xargs -I ASSET_ID curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/releases/assets/ASSET_ID"
# upload new assets
curl --data-binary @dist/webpty_linux_amd64.bin -H "Content-Type: application/octet-stream" -H "Authorization: Bearer $GITHUB_TOKEN" "https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID/assets?name=webpty_linux_amd64.bin"
curl --data-binary @dist/webpty_linux_arm.bin -H "Content-Type: application/octet-stream" -H "Authorization: Bearer $GITHUB_TOKEN" "https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID/assets?name=webpty_linux_arm.bin"
curl --data-binary @dist/webpty_mac_amd64.bin -H "Content-Type: application/octet-stream" -H "Authorization: Bearer $GITHUB_TOKEN" "https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID/assets?name=webpty_mac_amd64.bin"
curl --data-binary @dist/webpty_mac_arm.bin -H "Content-Type: application/octet-stream" -H "Authorization: Bearer $GITHUB_TOKEN" "https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASE_ID/assets?name=webpty_mac_arm.bin"