-
Notifications
You must be signed in to change notification settings - Fork 11
191 lines (168 loc) · 5.26 KB
/
go.yaml
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
---
name: test-build-release
on:
pull_request:
branches:
- main
- release-*
push:
branches:
- main
- release-*
tags:
- 'v*.*.*'
env:
GO_VERSION: 1.22
GOLANGCI_LINT_VERSION: v1.59
jobs:
# Pre jobs: Linter
linters:
name: linters
uses: ./.github/workflows/pre_linters.yaml
reviewer:
name: reviewer
uses: ./.github/workflows/pre_reviewer.yaml
go-test:
runs-on: ubuntu-latest
needs:
- linters
- reviewer
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run unit tests
run: make test
build:
runs-on: ubuntu-latest
needs: go-test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y make git -y
- name: Build (OS=linux-amd64)
env:
OS_ARCH: linux-amd64
run: |
make clean
make linux-amd64-container
make build-${OS_ARCH}
- name: Save artifacts (OS=linux-amd64)
uses: actions/upload-artifact@v4
with:
name: opct-linux-amd64
path: |
build/opct-*
- name: Build (OS=darwin-arm64)
env:
OS_ARCH: darwin-arm64
run: |
make clean
make build-${OS_ARCH}
- name: Save artifacts (OS=darwin-arm64)
uses: actions/upload-artifact@v4
with:
name: opct-darwin-arm64
path: |
build/opct-*
e2e:
needs: build
uses: ./.github/workflows/e2e.yaml
#
# Release job creates container images for latest (main) or release tags.
# When a tag is created, a new Github Release is created with the changelog.
#
release:
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: e2e
env:
PLATFORMS: linux/amd64
BUILD_EXPIRATION: never
PUSH: true
REPO_URL: https://quay.io/repository/opct/opct?tab=tags
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set vars for tag
if: startsWith(github.ref, 'refs/tags/')
run: |-
echo "BUILD_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set vars for main
if: github.ref == 'refs/heads/main'
run: |-
echo "BUILD_VERSION=latest" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_OPCT_USER }}
password: ${{ secrets.QUAY_OPCT_PASS }}
- name: "Build and push: quay.io/opct/opct"
uses: docker/build-push-action@v6
with:
platforms: ${{ env.PLATFORMS }}
push: ${{ env.PUSH }}
provenance: false
labels: |
quay.expires-after=${BUILD_EXPIRATION}
build-args: |
QUAY_EXPIRATION=${BUILD_EXPIRATION}
RELEASE_TAG=${{ env.BUILD_VERSION }}
tags: quay.io/opct/opct:${{ env.BUILD_VERSION }}
file: ./hack/Containerfile
- name: Install dependencies
if: startsWith(github.ref, 'refs/tags/')
run: |
sudo apt-get update
sudo apt-get install make git -y
- name: Build (all OS) for Github Release
if: startsWith(github.ref, 'refs/tags/')
run: |
make linux-amd64-container
make build-linux-amd64
make build-windows-amd64
make build-darwin-amd64
make build-darwin-arm64
# https://github.com/mikepenz/release-changelog-builder-action#configuration
- name: Build Changelog when tag is pushed
if: startsWith(github.ref, 'refs/tags/')
id: github_release
uses: mikepenz/[email protected]
with:
configuration: ".github/workflows/changelog-configuration.json"
# https://github.com/softprops/action-gh-release
- name: Create Release on Github when tag is pushed
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/[email protected]
env:
VERSION: ${{ steps.vars.outputs.tag }}
REPO: quay.io/opct/opct
with:
prerelease: true
files: |
build/opct-darwin-amd64
build/opct-darwin-amd64.sum
build/opct-darwin-arm64
build/opct-darwin-arm64.sum
build/opct-linux-amd64
build/opct-linux-amd64.sum
build/opct-windows-amd64.exe
build/opct-windows-amd64.exe.sum
body: |
## Changelog
${{steps.github_release.outputs.changelog}}
## Images
- [quay.io/opct/opct:${{ env.VERSION }}](${{ env.REPO_URL }})