-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (103 loc) · 3.67 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Go
on:
push:
branches: [ main ]
jobs:
test:
name: Vet and Test
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.21
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Configure github token
env:
TOKEN_USER: ${{ secrets.WORKFLOW_TOKEN_USER }}
TOKEN: ${{ secrets.WORKFLOW_TOKEN}}
run: |
git config --global url."https://${TOKEN_USER}:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Get dependencies
run: |
git config -l --global
go get -v -t -d ./...
- name: Generate
run: |
go generate ./...
env:
CI: false
- name: Vet
run: |
go vet ./...
- name: Test
run: go test -v ./...
- name: Test Race Conditions
run: go test -race -v ./...
build:
name: Build
needs: test
runs-on: ubuntu-20.04
strategy:
matrix:
os: [ linux ]
arch: [ amd64 ]
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
OUTPUT_BINARY: ${{ github.event.repository.name }}_${{ matrix.os }}_${{ matrix.arch }}
OUTPUT_ZIP: ${{ github.event.repository.name }}_${{ matrix.os }}_${{ matrix.arch }}.zip
COMMIT_DATE: $(git show -s --format=%ci ${{ github.sha }})
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ^1.21
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Configure github token
env:
TOKEN_USER: ${{ secrets.WORKFLOW_TOKEN_USER }}
TOKEN: ${{ secrets.WORKFLOW_TOKEN}}
run: |
git config --global url."https://${TOKEN_USER}:${TOKEN}@github.com".insteadOf "https://github.com"
- name: Get dependencies
run: |
git config -l --global
go get -v -t -d ./...
- name: Build
run: |
go generate ./...
go build -o ${{ env.OUTPUT_BINARY }} -v .
zip ${{ env.OUTPUT_ZIP }} ${{ env.OUTPUT_BINARY }}
env:
CI: false
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.OUTPUT_ZIP }}
path: ${{ env.OUTPUT_ZIP }}
- name: Upload S3 Release Asset
id: upload-s3-release-asset
env:
AWS_S3_BUCKET: releases.lab.dioad.net
AWS_ACCESS_KEY_ID: ${{ secrets.ARTIFACT_UPLOAD_S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.ARTIFACT_UPLOAD_S3_SECRET_ACCESS_KEY }}
AWS_REGION: 'eu-west-2'
run: |
sha256sum ${{ env.OUTPUT_ZIP }} > ${{ env.OUTPUT_ZIP }}_SHA256SUMS
aws s3api put-object \
--body ${{ env.OUTPUT_ZIP }} \
--bucket ${{ env.AWS_S3_BUCKET }} \
--key data/${{ github.event.repository.name }}/build/${{ env.OUTPUT_ZIP }} \
--tagging "Dioad/Project=${{ github.event.repository.name }}&Dioad/Version=${{ github.ref_type }}/${{ github.ref_name }}&Dioad/Commit=${{ github.sha }}&Dioad/CommitDate=${{ env.COMMIT_DATE }}&Dioad/OS=${{ matrix.os }}&Dioad/Architecture=${{ matrix.arch }}" \
--content-type "application/zip" \
--server-side-encryption AES256
aws s3 cp ${{ env.OUTPUT_ZIP }}_SHA256SUMS s3://${{ env.AWS_S3_BUCKET }}/data/${{ github.event.repository.name }}/build/${{ env.OUTPUT_ZIP }}_SHA256SUMS \
--no-guess-mime-type \
--content-type "text/plain" \
--no-progress \
--sse AES256