forked from k0sproject/k0s
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (81 loc) · 3.04 KB
/
build-k0s.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
name: "Build :: k0s"
on:
workflow_call:
inputs:
target-os:
type: string
required: true
description: The OS to build k0s for (linux or windows).
target-arch:
type: string
required: true
description: The architecture to build k0s for.
env:
MAKEFLAGS: -j
jobs:
build:
name: ${{ inputs.target-os }}-${{ inputs.target-arch }}
runs-on: ubuntu-22.04
env:
TARGET_OS: ${{ inputs.target-os }}
TARGET_ARCH: ${{ inputs.target-arch }}
steps:
- name: "Build :: Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0 # for `git describe`
persist-credentials: false
- name: "Build :: Prepare"
id: build-prepare
run: |
.github/workflows/prepare-build-env.sh
executableSuffix=''
if [ "$TARGET_OS" = windows ]; then
executableSuffix=.exe
fi
echo executable-suffix="$executableSuffix" >>"$GITHUB_OUTPUT"
- name: "Cache :: embedded binaries"
uses: actions/cache@v4
with:
key: build-k0s-${{ inputs.target-os }}-${{ inputs.target-arch }}-embedded-bins-${{ hashFiles('embedded-bins/**/*') }}
path: |
.bins.${{ inputs.target-os }}.stamp
bindata_${{ inputs.target-os }}
embedded-bins/staging/${{ inputs.target-os }}/bin/
embedded-bins/Makefile.variables
pkg/assets/zz_generated_offsets_${{ inputs.target-os }}.go
- name: "Cache :: GOCACHE"
uses: actions/cache@v4
with:
key: build-k0s-${{ inputs.target-os }}-${{ inputs.target-arch }}-gocache-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
build-k0s-${{ inputs.target-os }}-${{ inputs.target-arch }}-gocache-${{ github.ref_name }}-
path: |
build/cache/go/build
- name: "Cache :: GOMODCACHE"
uses: actions/cache@v4
with:
key: build-k0s-${{ inputs.target-os }}-${{ inputs.target-arch }}-gomodcache-${{ hashFiles('go.sum') }}
path: |
build/cache/go/mod
- name: "Build :: k0s"
run: |
make bindata
make --touch codegen
make build
echo "k0s${{ steps.build-prepare.outputs.executable-suffix }} binary size: **$(du -sh k0s${{ steps.build-prepare.outputs.executable-suffix }} | cut -f1)**" >>$GITHUB_STEP_SUMMARY
- name: "Upload :: k0s"
uses: actions/upload-artifact@v4
with:
name: k0s-${{ inputs.target-os }}-${{ inputs.target-arch }}
path: |
k0s${{ steps.build-prepare.outputs.executable-suffix }}
- name: "Build :: Airgap image list"
if: inputs.target-os != 'windows'
run: make airgap-images.txt && cat airgap-images.txt
- name: "Upload :: Airgap image list"
if: inputs.target-os != 'windows'
uses: actions/upload-artifact@v4
with:
name: airgap-image-list-${{ inputs.target-os }}-${{ inputs.target-arch }}
path: airgap-images.txt