-
Notifications
You must be signed in to change notification settings - Fork 16
228 lines (200 loc) · 8.45 KB
/
create-packages.yaml
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Create Distro packages
run-name: >-
Package-DKMS: ${{ github.head_ref || github.ref_name }}
# ========== TRIGGER ==========
on:
workflow_dispatch:
workflow_call:
secrets:
GHUB_TOKEN:
required: true
AZ_SAS_TOK:
required: true
outputs:
deb_name:
description: "Name of the resulting deb package."
value: ${{ jobs.build_distro_package.outputs.deb_name }}
rpm_name:
description: "Name of the resulting rpm package."
value: ${{ jobs.build_distro_package.outputs.rpm_name }}
tgz_name:
description: "Name of the resulting tarball."
value: ${{ jobs.build_distro_package.outputs.tgz_name }}
customer_name:
description: "Name of the customer, if customer-specific version."
value: ${{ jobs.build_distro_package.outputs.customer }}
jobs:
build_distro_package:
name: Build Distro package
runs-on:
- self-hosted
- builder
outputs:
deb_name: ${{ steps.build_dest.outputs.deb_name }}
rpm_name: ${{ steps.build_dest.outputs.rpm_name }}
tgz_name: ${{ steps.build_dest.outputs.tgz_name }}
customer: ${{ steps.build_dest.outputs.customer }}
strategy:
fail-fast: false
matrix:
distro: [
{ "container": "ubuntu:20.04", "bin_type": "deb" },
{ "container": "rockylinux:8.5", "bin_type": "rpm" },
{ "container": "rockylinux:8.5", "bin_type": "tgz" },
]
container:
image: ${{ matrix.distro.container }}
volumes:
- /mnt/cloud:/mnt/cloud
- /mnt/local:/mnt/local
options: "--entrypoint /bin/bash"
steps:
# --- INSTALL PRE-REQUISITES ---
- name: APT | Update cache
if: matrix.distro.container == 'ubuntu:20.04'
run: |
apt-get update -y
apt-get install -y software-properties-common
add-apt-repository -y ppa:git-core/ppa
apt-get update -y
- name: APT | Install pre-requisite packages
if: matrix.distro.container == 'ubuntu:20.04'
run: >-
apt-get -o Dpkg::Options::="--force-confdef"
-o Dpkg::Options::="--force-confold" -y install
git wget sudo gcc make automake dkms build-essential fakeroot devscripts debhelper findutils
env:
DEBIAN_FRONTEND: noninteractive
- name: DNF | Install epel
if: matrix.distro.container == 'rockylinux:8.5'
run: dnf install -y epel-release
- name: DNF | Install pre-requisite packages | rpm
if: matrix.distro.container == 'rockylinux:8.5' && matrix.distro.bin_type == 'rpm'
run: >-
dnf install -y --enablerepo=powertools
git wget sudo gcc make automake dkms rpm-build findutils
- name: DNF | Install pre-requisite packages | tgz
if: matrix.distro.container == 'rockylinux:8.5' && matrix.distro.bin_type == 'tgz'
run: >-
dnf install -y git wget sudo findutils
- name: Clean up the working directory
run: find -delete
# --- CLONE REPOSITORIES ---
- name: Checkout nfp-driver-kmods-repo
uses: Corigine/ci-libs/github_actions/utilities/checkout_corigine@main
with:
token: ${{ secrets.GHUB_TOKEN }}
fetch-depth: 0
- name: Install azcopy binary
run: |
wget https://azcopyvnext.azureedge.net/releases/release-10.24.0-20240326/azcopy_linux_amd64_10.24.0.tar.gz \
-O /tmp/downloadazcopy-v10-linux.tgz
tar -xvf /tmp/downloadazcopy-v10-linux.tgz -C /tmp/
sudo cp /tmp/azcopy_linux_amd64_*/azcopy /usr/bin/
# --- COLLECT BUILD INFORMATION ---
- name: Collect metadata
id: describe
run: |-2
BINARY_TYPE=${{ matrix.distro.bin_type }}
PACKAGE_NAME=$(.github/scripts/describe-head.sh --pkg_name)
echo "pkg_name=${PACKAGE_NAME}" | tee -a $GITHUB_OUTPUT
echo "binary_type=${BINARY_TYPE}" | tee -a $GITHUB_OUTPUT
# DEFAULT_BRANCH defaults to public-main, but can be used to denote
# other long-running branches for separate interim releases
DEFAULT_BRANCH=$(bash .github/scripts/describe-head.sh --default_branch)
echo "default_branch=${DEFAULT_BRANCH}" | tee -a $GITHUB_OUTPUT
env:
DISTRO: ${{ matrix.distro.container }}
HEAD_REF: ${{ github.head_ref || github.ref_name }}
# --- BUILD DKMS PACKAGE ---
- name: Ubuntu | Build DEB DKMS package
if: matrix.distro.bin_type == 'deb'
run: sudo -E .github/scripts/create-packages.sh -t d
env:
DEFAULT_BRANCH: ${{steps.describe.outputs.default_branch}}
HEAD_REF: ${{ github.head_ref || github.ref_name }}
- name: CentOS | Build RPM DKMS package
if: matrix.distro.bin_type == 'rpm'
run: sudo -E .github/scripts/create-packages.sh -t r
env:
DEFAULT_BRANCH: ${{steps.describe.outputs.default_branch}}
HEAD_REF: ${{ github.head_ref || github.ref_name }}
- name: CentOS | Build TAR package
if: matrix.distro.bin_type == 'tgz'
run: sudo -E .github/scripts/create-packages.sh -t t
env:
DEFAULT_BRANCH: ${{steps.describe.outputs.default_branch}}
HEAD_REF: ${{ github.head_ref || github.ref_name }}
- name: Prepare environment for upload
id: build_dest
shell: bash
run: |
DATE="$(date -u +%Y.%m.%d)"
temp_dir=$(pwd)
cd ${BIN_TYPE}/${BIN_PKG_NAME}
FINAL_PKG_NAME=$(ls ${BIN_PKG_NAME}*.${BIN_TYPE})
cd $temp_dir
echo "${BIN_TYPE}/${BIN_PKG_NAME}/${FINAL_PKG_NAME}"
echo "${BIN_PKG_NAME}"
# Determine the target folder for releases and pre-releases
TARGET_FOLDER=${HEAD_REF#*release-}
TARGET_FOLDER=${TARGET_FOLDER:0:5}
# If the default branch is not 'public-main', append the branch name,
# without 'wip-', to the upload destination.
# If the default branch is a customer branch (*-main), append
# customer name to directory.
case ${DEFAULT_BRANCH} in
"public-main")
readonly DST_SUFFIX=""
;;
"wip-"*)
readonly DST_SUFFIX=".${DEFAULT_BRANCH#wip-}"
;;
*"-main")
# Customer branch
readonly CUSTOMER="${DEFAULT_BRANCH%-main}"
readonly DST_SUFFIX=".${CUSTOMER}"
;;
*)
readonly DST_SUFFIX=""
;;
esac
case $HEAD_REF in
release-[0-9][0-9].[0-9][0-9].[0-9]|\
${DEFAULT_BRANCH%-main}-release-[0-9][0-9].[0-9][0-9].[0-9])
# Release tag
AZURE_PATH="binaries/nfp-drv-dkms/releases${DST_SUFFIX}/${TARGET_FOLDER}"
;;
prerelease-[0-9][0-9].[0-9][0-9].[0-9]-rc[0-9]|\
${DEFAULT_BRANCH%-main}-prerelease-[0-9][0-9].[0-9][0-9].[0-9]-rc[0-9])
# Prerelease tag
AZURE_PATH="binaries/nfp-drv-dkms/prereleases${DST_SUFFIX}/${TARGET_FOLDER}"
;;
${DEFAULT_BRANCH})
AZURE_PATH="binaries/nfp-drv-dkms/interim${DST_SUFFIX}/${BIN_PKG_NAME}"
;;
*)
AZURE_PATH="tmp/nfp_drv_dkms_builds${DST_SUFFIX}"
AZURE_PATH="$AZURE_PATH/${{ github.actor }}/${DATE}"
;;
esac
AZURE_DEST=$(echo "${AZURE_PATH}/${BIN_TYPE}")
echo "${{ matrix.distro.bin_type }}_name=$(echo "${FINAL_PKG_NAME}")" | tee -a $GITHUB_OUTPUT
echo "customer=${CUSTOMER}" | tee -a $GITHUB_OUTPUT
echo "dkms_bin_path=$(echo "${BIN_TYPE}/${BIN_PKG_NAME}/${FINAL_PKG_NAME}")" | tee -a $GITHUB_OUTPUT
echo "azure_dest=${AZURE_DEST}" | tee -a $GITHUB_OUTPUT
env:
DEFAULT_BRANCH: ${{steps.describe.outputs.default_branch}}
BIN_TYPE: '${{ steps.describe.outputs.binary_type }}'
BIN_PKG_NAME: '${{ steps.describe.outputs.pkg_name }}'
HEAD_REF: ${{ github.head_ref || github.ref_name }}
# --- UPLOAD DKMS PACKAGE TO AZURE ---
- name: Upload to DKMS Package to Azure storage
uses: Corigine/ci-libs/github_actions/azure/azcopy_upload_sync@main
with:
connection-string: ${{ secrets.AZ_SAS_TOK }}
src: '${{ steps.build_dest.outputs.dkms_bin_path }}'
dst: '${{steps.build_dest.outputs.azure_dest}}'
- name: Clean up afterwards
if: always()
run: find -delete