-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (138 loc) · 4.61 KB
/
build-release.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
name: "build packages and repo"
on:
push:
tags: ['v*']
branches:
- "main"
workflow_dispatch:
pull_request:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write # write access required to attach .deb files to release
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
jobs:
build-package:
runs-on: ubuntu-${{matrix.distro}}
strategy:
fail-fast: false
matrix:
distro:
- 20.04 # focal
- 22.04 # jammy
- 24.04 # noble
env:
OS_VERSION: ${{ matrix.distro }}
steps:
- name: "Map to OS version name "
id: map_to_release
run: |
declare -A version_number_to_name=(["20.04"]="focal" ["22.04"]="jammy" ["24.04"]="noble")
version_name=${version_number_to_name[$OS_VERSION]}
echo "Building package for: $version_name"
echo "OS_NAME=${version_name}" >> $GITHUB_ENV
- name: "install dependencies"
env:
DEBIAN_FRONTEND: noninteractive
run: |
echo "Running on $OS_NAME"
sudo apt-get update
# for checkout and go
sudo apt-get install -y git curl
# needed for bootstrapping mk-build-deps
sudo apt-get install -y devscripts equivs
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-tags: true
fetch-depth: 0
show-progress: false
- name: "setup go environment"
id: go
uses: actions/setup-go@v5
with:
go-version: '1.23.0'
- name: "compile + package"
run: |
git config --global --add safe.directory "$PWD"
debian/doch.pl --project do-dcgm-exporter --distribution $OS_NAME > debian/changelog
sudo mk-build-deps --install --tool='apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes' debian/control
sudo make build
sudo dpkg-buildpackage -b --no-sign
# don't include build-deps
rm *build-deps*.deb
sudo dpkg -I ../*.deb
sudo dpkg --contents ../*.deb
mv ../do-dcgm-exporter_*.deb .
# add focal/jammy/noble suffix to be able to distinguish when uploading to releases
for file in do-dcgm-exporter_*.deb; do
new_name="${file%%.deb*}-$OS_NAME.deb"
mv "$file" "$new_name"
done
ls -lh
- uses: actions/upload-artifact@v4
with:
name: pool-${{ env.OS_NAME }}
path: '*.deb'
build-repo:
if: ${{ github.ref_type == 'tag' }}
runs-on: ubuntu-24.04
needs: build-package
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
outputs:
page_url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: "install dependencies"
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y git
sudo apt-get install -y gpg dpkg-dev apt-utils
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: pool-focal
path: pool/focal
- uses: actions/download-artifact@v4
with:
name: pool-jammy
path: pool/jammy
- uses: actions/download-artifact@v4
with:
name: pool-noble
path: pool/noble
- name: "upload .debs to Github releases/tag"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ls -la pool/*
gh release list
for file in **/**/do-dcgm-exporter_*.deb; do
echo "uploading $file for release with name ${{ github.ref_name }}"
# relies on the github release having the same name as the tag!
gh release upload --clobber ${{ github.ref_name }} $file
done
- uses: ./.github/actions/deb-repo
with:
repo_root: repo_root
dist_pool: pool # filepath under which the .debs are
private_key: ${{ secrets.PRIVATE_KEY }}
private_key_email: ${{ secrets.PRIVATE_KEY_EMAIL }}
- uses: actions/configure-pages@v5
with:
enablement: true
- uses: actions/upload-pages-artifact@v3
with:
path: 'repo_root'
- uses: actions/deploy-pages@v4
id: deployment
test-repo:
runs-on: ubuntu-24.04
needs: build-repo
steps:
- name: test
run: |
echo ${{ needs.build-repo.outputs.page_url }}