-
Notifications
You must be signed in to change notification settings - Fork 145
83 lines (68 loc) · 2.13 KB
/
build-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
name: Go
on:
release:
types: [ "created" ]
jobs:
build_and_upload_assets:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.17.2
- name: Update go.mod to use Go 1.17
run: |
sed -i 's/go 1.20/go 1.17/' go.mod
- name: Download dependencies
run: go mod tidy
- name: Build Linux arm64
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o tgState main.go
- name: Zip Linux amd64
run: |
sudo apt-get install -y zip
zip tgState_arm64.zip tgState
- name: Delete tgState arm64
run: |
rm tgState
- name: Build Linux amd64
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o tgState main.go
- name: Zip Linux amd64
run: |
sudo apt-get install -y zip
zip tgState.zip tgState
- name: Upload server asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./tgState.zip
asset_name: tgState.zip
asset_content_type: application/zip
- name: Upload server asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./tgState_arm64.zip
asset_name: tgState_arm64.zip
asset_content_type: application/zip
- 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.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: csznet/tgstate:latest