-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (70 loc) · 2.21 KB
/
ci.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
88
name: CI
on:
push:
tags:
- 'v*.*.*'
release:
types: [created]
env:
GO_VERSION: 1.22
CGO_ENABLED: 0
jobs:
build-binary:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
os: [linux, darwin, windows]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set output
id: set_output
run: |
echo "tag=`basename ${{ github.ref }}`" >> $GITHUB_OUTPUT
if [ ${{ matrix.os }} = "windows" ]; then
echo "exe=bbx-${{ matrix.os }}-${{ matrix.arch }}.exe" >> $GITHUB_OUTPUT
else
echo "exe=bbx-${{ matrix.os }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
fi
echo ${{ steps.set_output.outputs.tag }}
- name: show
run: |
echo ${{ steps.set_output.outputs.tag }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Build binary
run: |
export GOOS=${{ matrix.os }}
export GOARCH=${{ matrix.arch }}
export CGO_ENABLED=${{ env.CGO_ENABLED }}
go build -o ${{ steps.set_output.outputs.exe }}
- name: Release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name:
files: |
${{ steps.set_output.outputs.exe }}
build-image:
runs-on: ubuntu-latest
needs: build-binary
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: show
run: |
echo ${{ steps.set_output.outputs.tag }}
- name: Build and push Docker image
run: |
# docker buildx build --build-arg IMAGE=golang:1.22 --platform linux/amd64,linux/arm64 -t snail2sky/bbx:latest . --push
docker buildx build --build-arg IMAGE=golang:1.22 --platform linux/amd64 -t snail2sky/bbx:${{ steps.set_output.outputs.tag }} . --push