-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (105 loc) · 3.62 KB
/
build-binaries.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
126
name: Build Binaries
on: [ push ]
jobs:
test:
strategy:
fail-fast: false
max-parallel: 4
matrix:
os: [ ubuntu-latest, macOS-latest ]
architecture: [ arm64, amd64 ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: sudo apt-get update -qq
- name: Set up Go
uses: actions/[email protected]
with:
go-version-file: go.mod
- name: Run lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: Run tests
run: make test
build-n-publish:
strategy:
fail-fast: false
max-parallel: 4
matrix:
os: [ ubuntu-latest, macOS-latest ]
architecture: [ arm64, amd64 ]
runs-on: ${{ matrix.os }}
if: startsWith(github.event.ref, 'refs/tags')
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get latest tag
id: tag
run: echo "TAG=$(git describe --tags)" >> $GITHUB_ENV
- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: sudo apt-get update -qq
- name: Set up Go
uses: actions/[email protected]
with:
go-version-file: go.mod
- name: Build binary
run: |
GOARCH=${{ matrix.architecture }} make build
mv build/qli qli-${{ env.TAG }}-${{ runner.os }}-${{ matrix.architecture }}
- name: Generate Checksum
id: checksum
run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then
shasum -a 256 qli-${{ env.TAG }}-${{ runner.os }}-${{ matrix.architecture }} > qli-${{ env.TAG }}-${{ runner.os }}-${{ matrix.architecture }}.sha256
else
sha256sum qli-${{ env.TAG }}-${{ runner.os }}-${{ matrix.architecture }} > qli-${{ env.TAG }}-${{ runner.os }}-${{ matrix.architecture }}.sha256
fi
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: qli-${{ env.TAG }}-${{ runner.os }}-${{ matrix.architecture }}
path: |
qli-${{ env.TAG }}-${{ runner.os }}-${{ matrix.architecture }}
qli-${{ env.TAG }}-${{ runner.os }}-${{ matrix.architecture }}.sha256
build-docker-n-publish:
runs-on: ubuntu-latest
needs: test
permissions:
packages: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Define the tag for the Docker image
# actions/checkout is making a shallow copy, so unless it's a tag event,
# tag will be empty; in such case, use shortened commit SHA
id: tag
run: echo "TAG=$(git describe --tags || git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v5
with:
context: .
file: ./build/Dockerfile
push: ${{ startsWith(github.event.ref, 'refs/tags') }}
provenance: false
tags: ghcr.io/qase-tms/qase-cli:${{ env.TAG }},ghcr.io/qase-tms/qase-cli:latest
platforms: linux/amd64,linux/arm64
build-args: |
VERSION=${{ env.TAG }}