Skip to content

Commit 279ca3b

Browse files
feat: add version and deb build
Co-authored-by: Alessio Perugini <alessio@perugini.xyz>
1 parent 7823829 commit 279ca3b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

debian/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@ FROM golang:1.24.2 AS go
22

33
ARG BINARY_NAME
44
RUN test -n "${BINARY_NAME}" || (echo "Error: BINARY_NAME is not set" && exit 1)
5+
ARG VERSION
6+
RUN test -n "${VERSION}" || (echo "Error: VERSION is not set" && exit 1)
7+
ARG ARCH
8+
RUN test -n "${ARCH}" || (echo "Error: ARCH is not set" && exit 1)
59

610
COPY . /app
711
WORKDIR /app
8-
RUN GOOS=linux go build -o ${BINARY_NAME} ./cmd/${BINARY_NAME}
12+
RUN GOOS=linux GOARCH=${ARCH} go build -ldflags "-X 'main.Version=${VERSION}'" -o ${BINARY_NAME} ./cmd/${BINARY_NAME}
913

1014
FROM debian:bookworm AS debian
1115

12-
ARG VERSION="1.0.0"
16+
ARG VERSION
17+
RUN test -n "${VERSION}" || (echo "Error: VERSION is not set" && exit 1)
1318
ARG REVISION="1"
19+
ARG ARCH
20+
RUN test -n "${ARCH}" || (echo "Error: ARCH is not set" && exit 1)
1421
ARG DEB_NAME
1522
RUN test -n "${DEB_NAME}" || (echo "Error: DEB_NAME is not set" && exit 1)
1623
ARG BINARY_NAME
@@ -21,9 +28,10 @@ RUN apt-get update && apt-get install -y sed
2128
COPY ./debian/${DEB_NAME} /${DEB_NAME}/
2229
COPY --from=go /app/${BINARY_NAME} /${DEB_NAME}/usr/bin/${BINARY_NAME}
2330

24-
RUN sed -i "s/ARCH/$(dpkg --print-architecture)/" /${DEB_NAME}/DEBIAN/control && \
31+
RUN sed -i "s/ARCH/${ARCH}/" /${DEB_NAME}/DEBIAN/control && \
32+
sed -i "s/VERSION/${VERSION}/" /${DEB_NAME}/DEBIAN/control && \
2533
dpkg-deb --build --root-owner-group /${DEB_NAME} &&\
26-
mv /${DEB_NAME}.deb "/${DEB_NAME}_${VERSION}-${REVISION}_$(dpkg --print-architecture).deb"
34+
mv /${DEB_NAME}.deb "/${DEB_NAME}_${VERSION}-${REVISION}_${ARCH}.deb"
2735

2836
FROM scratch
2937

debian/router/DEBIAN/control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: arduino-router
2-
Version: 1.0
2+
Version: VERSION
33
Architecture: ARCH
44
Maintainer: arduino <support@arduino.cc>
55
Description: Arduino application router

0 commit comments

Comments
 (0)