-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (69 loc) · 2.72 KB
/
step_packaging.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
name: packaging
run-name: Packaging
on:
workflow_call:
jobs:
packaging:
name: packaging
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
- name: Download go build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts
- name: Get version
id: vars
run: |
if [[ "${GITHUB_EVENT_NAME}" == "push" && "${GITHUB_REF_TYPE}" == "tag" ]]; then
REF_NAME=$(echo "${GITHUB_REF_NAME//\//-}")
CEEMS_VERSION=$(echo "${REF_NAME//v}")
echo "version=${CEEMS_VERSION}" >> $GITHUB_OUTPUT
else
echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT
fi
echo "goos=linux" >> $GITHUB_OUTPUT
# Build RPM and DEB packages
- name: Build deb and rpm packages
run: |
# # Replace any '/' with '-' for non tag workflows
# export REF_NAME=$(echo "${GITHUB_REF_NAME//\//-}")
# # Strip v from tag name, eg v0.1.0 -> 0.1.0
# export CEEMS_VERSION=$(echo "${REF_NAME//v}")
# export GOOS=linux
# Ensure target directory exists
mkdir -p .tarballs
# Build packages
# Use a simple for loop instead of matrix strategy as building packages
# is a very rapid process and we pay more price by repeating all the steps
# if using a matrix strategy
for arch in amd64 arm64; do
for packager in rpm deb; do
for app in ceems_exporter ceems_api_server ceems_lb; do
GOARCH=${arch} nfpm pkg --config build/package/${app}/nfpm.yml --packager ${packager} --target .tarballs/${app}-${{ steps.vars.outputs.version }}-${{ steps.vars.outputs.goos }}-${arch}.${packager}
done
done
done
- name: Test deb packages
run: |
# Install all CEEMS components
for app in ceems_exporter ceems_api_server ceems_lb; do
GOARCH=amd64 sudo apt-get install ./.tarballs/${app}-${{ steps.vars.outputs.version }}-${{ steps.vars.outputs.goos }}-amd64.deb
done
# Test systemd service of each CEEMS component
for app in ceems_exporter ceems_api_server ceems_lb; do
systemctl is-active --quiet "${app}.service" && echo "${app}" is running
done
- name: Upload release artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: .tarballs
retention-days: 1