-
Notifications
You must be signed in to change notification settings - Fork 5
87 lines (73 loc) · 3.46 KB
/
go.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Go
on:
push:
branches: [ master ]
tags: [ v* ]
pull_request:
branches: [ master ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20+
uses: actions/setup-go@v2
with:
go-version: ^1.20
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: go get -v -t -d ./...
- name: Build (Smoke test)
run: CGO_ENABLED=0 go build -v ./...
- name: Test
run: CGO_ENABLED=0 go test -v ./...
- name: Build Releases
run: |
mkdir bin
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o bin/minibox-macos-amd64 ./cmd/minibox
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/minibox-macos-arm64 ./cmd/minibox
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o bin/minibox-freebsd-amd64 ./cmd/minibox
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/minibox-linux-amd64 ./cmd/minibox
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags -H=windowsgui -o bin/minibox-windows-amd64.exe ./cmd/minibox
- name: Upload builds
uses: actions/upload-artifact@v2
with:
name: bin
path: bin/*
release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: build
steps:
- name: Download builds
uses: actions/download-artifact@v1
with:
name: bin
- name: Zip builds
run: |
for i in bin/*
do
OUT="$PWD/$(basename $i).zip"
cd "$(dirname $i)"
zip "$OUT" "$(basename $i)"
cd -
done
- name: Get the tag name
id: tag
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.VERSION }}
release_name: ${{ steps.tag.outputs.VERSION }}
draft: true
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: minibox-macos-amd64.zip, asset_name: minibox-macos-amd64.zip, asset_content_type: application/zip } }
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: minibox-macos-arm64.zip, asset_name: minibox-macos-arm64.zip, asset_content_type: application/zip } }
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: minibox-freebsd-amd64.zip, asset_name: minibox-freebsd-amd64.zip, asset_content_type: application/zip } }
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: minibox-linux-amd64.zip, asset_name: minibox-linux-amd64.zip, asset_content_type: application/zip } }
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: minibox-windows-amd64.exe.zip, asset_name: minibox-windows-amd64.exe.zip, asset_content_type: application/zip } }