-
Notifications
You must be signed in to change notification settings - Fork 78
103 lines (88 loc) · 3.61 KB
/
build-package.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
name: Build Agent V3 packages
on:
push:
branches:
- packaging
defaults:
run:
shell: bash
concurrency:
group: ${{ github.ref_name }}-build
cancel-in-progress: true
permissions:
contents: read
jobs:
vars:
name: Setup variables
runs-on: ubuntu-22.04
outputs:
go_code_md5: ${{ steps.vars.outputs.go_code_md5 }}
package_cache_hit: ${{ steps.package-cache.outputs.cache-hit }}
packaging_md5: ${{ steps.vars.outputs.packaging_md5 }}
actions_md5: ${{ steps.vars.outputs.actions_md5 }}
package_build_md5: ${{ steps.vars.outputs.package_build_md5 }}
steps:
- name: Checkout Repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Output Variables
id: vars
run: |
go_code_md5=$(find . -type f \( -name "*.go" -o -name go.mod -o -name go.sum -o -name -o -name "*.proto" -o -name "*.pgo" -o -name "buf.yaml" -o -name "data-plane-api.yaml" \) -not -path "./site*" -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1 }')
echo "go_code_md5=$go_code_md5" >> $GITHUB_OUTPUT
packaging_md5=$(find scripts/packages nginx-agent.conf Makefile.packaging .nfpm.yaml -type f -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1 }')
echo "packaging_md5=$packaging_md5" >> $GITHUB_OUTPUT
actions_md5=$(find .github -type f -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1 }')
echo "actions_md5=$actions_md5" >> $GITHUB_OUTPUT
package_build_md5=$(echo "$go_code_md5 $packaging_md5" | md5sum | awk '{ print $1 }')
echo "package_build_md5=$package_build_md5" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: Fetch Cached Package Artifacts
id: package-cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: build
key: agent-v3-packages-${{ steps.vars.outputs.package_build_md5 }}
#lookup-only: true
- name: Display cache files
run: find build -type f
build-packages:
if: ${{ needs.vars.outputs.package_cache_hit != 'true' }}
name: Build packages
runs-on: ubuntu-22.04
needs: [vars]
steps:
- name: Checkout Repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
- name: Setup package build environment
run: |
sudo apt-get update
sudo apt-get install -y gpgv1 monkeysphere
go install github.com/goreleaser/nfpm/v2/cmd/[email protected]
export PATH=$PATH:~/go/bin
nfpm --version
- name: Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0
- name: Build Docker Image
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
file: scripts/packages/packager/Dockerfile
tags: build-signed-packager:1.0.0
context: '.'
push: false
load: true
no-cache: true
build-args: |
package_type=signed-package
- name: Build Packages
env:
INDIGO_GPG_AGENT: ${{ secrets.INDIGO_GPG_AGENT }}
NFPM_SIGNING_KEY_FILE: .key.asc
run: |
export PATH=$PATH:~/go/bin
echo "$INDIGO_GPG_AGENT" | base64 --decode > ${NFPM_SIGNING_KEY_FILE}
make clean package
- name: Store Artifacts in Cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: build
key: agent-v3-packages-${{ needs.vars.outputs.package_build_md5 }}