-
Notifications
You must be signed in to change notification settings - Fork 19
71 lines (59 loc) · 1.61 KB
/
build.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
# SPDX-FileCopyrightText: 2023 SUSE LLC
#
# SPDX-License-Identifier: Apache-2.0
name: Build
on:
pull_request:
types:
- opened
- reopened
- synchronize
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: '1.21'
- name: Install dependencies
run: |
go get ./...
- name: Compute version
run: |
tag=$(git describe --tags --abbrev=0)
version=$(git describe --tags --abbrev=0 | cut -f 3 -d '-')
offset=$(git rev-list --count ${tag}..)
echo "VERSION=$tag-$offset" >> "$GITHUB_ENV"
- name: Build
run: |
mkdir -p ./bin
go build \
-tags netgo \
-ldflags "-X github.com/uyuni-project/uyuni-tools/shared/utils.Version=${{ env.VERSION }}" \
-o ./bin \
./...
- name: Build with all tags
run: |
mkdir -p ./bin
go build \
-tags netgo,nok8s,ptf \
-ldflags "-X github.com/uyuni-project/uyuni-tools/shared/utils.Version=${{ env.VERSION }}" \
-o ./bin \
./...
- name: Unit tests with all tags
run: go test -tags nok8s,ptf ./...
- name: Unit tests
run: go test ./...
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: binaries
path: ./bin/*