-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (104 loc) · 3.33 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
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
name: Build
on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
concurrency:
group: ${{ github.workflow }}-${{ github.ref_type }}
cancel-in-progress: true
jobs:
Build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
env:
GOPROXY: https://goproxy.io,direct
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: false
check-latest: true
- name: Tidy
run: make tidy
- name: Build
run: make build-clean
- name: UPX
run: |
set -xe
export temp_dir=$(mktemp -d)
cd "$temp_dir"
wget https://github.com/upx/upx/releases/download/v4.0.2/upx-4.0.2-amd64_linux.tar.xz
tar -xvf upx-4.0.2-amd64_linux.tar.xz upx-4.0.2-amd64_linux/upx
mv ./upx-4.0.2-amd64_linux/upx .
cd -
"$temp_dir/upx" --no-color --mono --no-progress --ultra-brute --no-backup ./bin/ingest
"$temp_dir/upx" --test ./bin/ingest
rm -rfv "$temp_dir"
- name: Test
run: make test
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage.out
flags: unittests
fail_ci_if_error: false
verbose: true
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: ingest
path: ./bin/ingest
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ./bin/ingest
- name: Docker Meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/${{ github.repository }}/ingest
tags: |
type=edge,enable=${{ github.event_name == 'push' && github.ref_protected && github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
labels: |
maintainer=${{ github.repository_owner }}
org.opencontainers.image.authors=${{ github.repository_owner }}
flavor: |
latest=${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/') }}
prefix=,onlatest=false
suffix=,onlatest=false
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Image Build and Push
id: docker_build_and_push
uses: docker/build-push-action@v4
with:
push: true
pull: true
context: .
file: Dockerfile
no-cache: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
timeout-minutes: 10