-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (139 loc) · 5.8 KB
/
Copy pathbuild-deb.yaml
File metadata and controls
161 lines (139 loc) · 5.8 KB
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
name: Build and Publish Debian Package
on:
push:
jobs:
create_release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
- id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: Release ${{ github.ref_name }}
body: Automated release for tag ${{ github.ref_name }}
draft: false
prerelease: false
build-deb:
runs-on: ubuntu-latest
env:
DEB_BUILD_OPTIONS: nocheck
strategy:
matrix:
distro: [debian-12, debian-11, ubuntu-24.04, ubuntu-22.04]
include:
- distro: debian-12
image: debian:12
os: debian
version: bookworm
- distro: debian-11
image: debian:11
os: debian
version: bullseye
- distro: ubuntu-24.04
image: ubuntu:24.04
os: ubuntu
version: noble
- distro: ubuntu-22.04
image: ubuntu:22.04
os: ubuntu
version: jammy
container:
image: ${{ matrix.image }}
steps:
- name: Install build dependencies
run: |
apt-get update
apt-get install -y build-essential devscripts debhelper autotools-dev autoconf-archive pkg-config fakeroot sed git tar gzip python3-pip python3-venv curl jq libyaml-cpp-dev
curl -1sLf 'https://dl.cloudsmith.io/basic/robertburger/robotkernel/setup.deb.sh' | bash
apt-get update
apt-get install -y robotkernel-service-helper robotkernel-dev service-provider-module-tty-dev service-provider-memory-inspection-dev
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Mark working directory as safe
run: git config --global --add safe.directory $GITHUB_WORKSPACE
- name: update branch name and version
run: |
safe_branch=$(echo "${GITHUB_REF_NAME}" | tr '/' '-')
VERSION=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
sed "s|PACKAGE_VERSION|$VERSION|" configure.ac.in > configure.ac
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Build .deb package
shell: bash
run: |
# baue mit dpkg-buildpackage (ohne signieren)
CODENAME=$(lsb_release -sc)
DEBEMAIL="robert.burger@dlr.de"
DEBFULLNAME="Robert Burger"
if ! dpkg-parsechangelog | grep -q "~${CODENAME}"; then
dch --local ~${CODENAME} "Build for ${CODENAME}";
fi
dpkg-buildpackage -us -uc -S
dpkg-buildpackage -us -uc -d
- name: Collect .deb artifact
run: |
mkdir -p artifacts/${{ matrix.os }}/${{ matrix.version }}
mv ../module-tty*.deb artifacts/${{ matrix.os }}/${{ matrix.version }}
- name: Set sanitized image name
id: sanitize
run: |
version=$(dpkg-parsechangelog | sed -n 's/^Version: //p')
echo "sanitized_image=$(echo "${version}_amd64" | tr '/:' '--')" >> $GITHUB_OUTPUT
- name: Upload .deb package artifact
uses: actions/upload-artifact@v4
with:
name: service-provider-module-tty-${{ steps.sanitize.outputs.sanitized_image }}
path: artifacts/${{ matrix.os }}/${{ matrix.version }}/
- name: Debug artifact files
run: |
ls -l ./artifacts/${{ matrix.os }}/${{ matrix.version }}/
# Fetch the release upload URL dynamically on tag builds
- name: Get Release Upload URL
if: startsWith(github.ref, 'refs/tags/')
id: get_release
run: |
release_json=$(curl -sSL \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${GITHUB_REF_NAME}")
upload_url=$(echo "$release_json" | jq -r '.upload_url' | sed -e "s/{?name,label}//")
echo "upload_url=$upload_url" >> $GITHUB_OUTPUT
env:
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Upload asset manually with curl
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
UPLOAD_URL: ${{ steps.get_release.outputs.upload_url }}
FILE_PATH: ./artifacts/${{ matrix.os }}/${{ matrix.version }}/service-provider-module-tty_${{ steps.sanitize.outputs.sanitized_image }}.deb
FILE_NAME: service-provider-module-tty_${{ steps.sanitize.outputs.sanitized_image }}.deb
run: |
echo "Uploading $FILE_PATH to $UPLOAD_URL?name=$FILE_NAME"
curl --fail -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/vnd.debian.binary-package" \
--data-binary @"$FILE_PATH" \
"$UPLOAD_URL?name=$FILE_NAME"
- name: Upload to Cloudsmith (${{ matrix.os }}/${{ matrix.version }})
#if: startsWith(github.ref, 'refs/tags/')
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
shell: bash
run: |
FILENAME="artifacts/${{ matrix.os }}/${{ matrix.version }}/service-provider-module-tty_${{ steps.sanitize.outputs.sanitized_image }}.deb"
python3 -m venv cloudsmith
cd cloudsmith
source bin/activate
python3 -m pip install --upgrade pip
pip3 install cloudsmith-cli
cloudsmith push deb robertburger/robotkernel/${{ matrix.os }}/${{ matrix.version }} ../${FILENAME} \
--republish \
--api-key "$CLOUDSMITH_API_KEY"