Skip to content

Commit feb07cf

Browse files
taskfile: build deb pkgs
Ship .deb packages for all supported linux archs
1 parent a99efdd commit feb07cf

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

DistTasks.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ tasks:
7676
-p "{{.BUILD_PLATFORM}}"
7777
7878
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
79+
- task: build_deb
80+
vars:
81+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
82+
ARCH: "i386"
7983

8084
vars:
8185
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd32"
@@ -97,6 +101,10 @@ tasks:
97101
-p "{{.BUILD_PLATFORM}}"
98102
99103
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
104+
- task: build_deb
105+
vars:
106+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
107+
ARCH: "amd64"
100108

101109
vars:
102110
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd64"
@@ -118,6 +126,10 @@ tasks:
118126
-p "{{.BUILD_PLATFORM}}"
119127
120128
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
129+
- task: build_deb
130+
vars:
131+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
132+
ARCH: "armhf"
121133

122134
vars:
123135
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
@@ -139,6 +151,10 @@ tasks:
139151
-p "{{.BUILD_PLATFORM}}"
140152
141153
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
154+
- task: build_deb
155+
vars:
156+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
157+
ARCH: "armel"
142158

143159
vars:
144160
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
@@ -160,6 +176,10 @@ tasks:
160176
-p "{{.BUILD_PLATFORM}}"
161177
162178
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
179+
- task: build_deb
180+
vars:
181+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
182+
ARCH: "arm64"
163183

164184
vars:
165185
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64"
@@ -231,3 +251,16 @@ tasks:
231251
cmds:
232252
- mkdir --parents {{.DIST_DIR}}
233253
- cp ./internal/cli/configuration/configuration.schema.json {{.DIST_DIR}}/{{.PROJECT_NAME}}_{{.VERSION}}_configuration.schema.json
254+
255+
build_deb:
256+
desc: Builds the deb package
257+
cmds:
258+
- |
259+
docker build \
260+
--build-arg BINARY_NAME={{.PROJECT_NAME}} \
261+
--build-arg DEB_NAME={{.PROJECT_NAME}} \
262+
--build-arg VERSION={{ .VERSION }} \
263+
--build-arg ARCH={{ .ARCH }} \
264+
--build-arg GO_BINARY={{ .GO_BINARY }} \
265+
--output=./dist \
266+
-f debian/Dockerfile .

debian/Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM debian:bookworm AS debian
2+
3+
ARG VERSION
4+
RUN test -n "${VERSION}" || (echo "Error: VERSION is not set" && exit 1)
5+
6+
ARG REVISION="1"
7+
ARG ARCH
8+
RUN test -n "${ARCH}" || (echo "Error: ARCH is not set" && exit 1)
9+
10+
ARG DEB_NAME
11+
RUN test -n "${DEB_NAME}" || (echo "Error: DEB_NAME is not set" && exit 1)
12+
13+
ARG BINARY_NAME
14+
RUN test -n "${BINARY_NAME}" || (echo "Error: BINARY_NAME is not set" && exit 1)
15+
16+
RUN apt-get update && apt-get install -y sed
17+
18+
ARG GO_BINARY
19+
20+
COPY ./debian/${DEB_NAME} /${DEB_NAME}/
21+
COPY ./${GO_BINARY} /${DEB_NAME}/usr/bin/${BINARY_NAME}
22+
23+
# Go application are tagged with `v` prefix, this remove the first v if present
24+
RUN export VERSION=$(echo "${VERSION}" | sed -e "s/^v\(.*\)/\1/") && \
25+
sed -i "s/\$ARCH/${ARCH}/" /${DEB_NAME}/DEBIAN/control && \
26+
sed -i "s/\$VERSION/${VERSION}/" /${DEB_NAME}/DEBIAN/control && \
27+
dpkg-deb --build --root-owner-group /${DEB_NAME} &&\
28+
mv /${DEB_NAME}.deb "/${DEB_NAME}_${VERSION}-${REVISION}_${ARCH}.deb"
29+
30+
FROM scratch
31+
32+
COPY --from=debian /*.deb /

debian/arduino-cli/DEBIAN/control

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Package: arduino-cli
2+
Version: $VERSION
3+
Architecture: $ARCH
4+
Maintainer: arduino <[email protected]>
5+
Description: Arduino CLI

0 commit comments

Comments
 (0)