Skip to content

Commit df7d98b

Browse files
committed
build: Support building new revisions for tags
A new action has been created in build_revision.yaml with a workflow dispatch that takes two optional input parameters, tag and revision. If provided, the release with the tag will be adjusted with new builds versionened with the revision. Otherwise the latest tag is determined, its release information fetched and the current package revision determined from that, then incremented by one to act as the new revision. The goal of this action is to be able to do additional builds of the *same* code version, against a newer dependency versions (e.g. on a libcamera0 update).
1 parent ff539cd commit df7d98b

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

.github/ci/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ FROM build as deb_make
3131
ARG GIT_VERSION
3232
ARG BUILD_TYPE="generic"
3333
ENV DEB_BUILD_PROFILES="$BUILD_TYPE"
34+
ARG DEB_REVISION="1"
3435

3536
RUN apt-get build-dep -y $PWD
3637
RUN . /etc/os-release && \
37-
export RELEASE_SUFFIX="$VERSION_CODENAME" && \
38+
export RELEASE_SUFFIX="$VERSION_CODENAME-$DEB_REVISION" && \
3839
dpkg-buildpackage -us -uc -b
3940

4041
RUN mkdir -p /deb && mv ../*.deb /deb/
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: "Build package revisions for latest release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "release to revision"
8+
required: false
9+
default: ''
10+
deb_revision:
11+
description: "Revision to use for the debian packages"
12+
required: false
13+
default: ''
14+
15+
jobs:
16+
vars:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
tag: ${{ steps.get_tag.outputs.tag }}
20+
revision: ${{ steps.get_revision.outputs.revision }}
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
submodules: recursive
27+
- name: Determine latest tag
28+
id: get_tag
29+
run: |
30+
set -e
31+
tag="${{ github.event.inputs.tag }}"
32+
if [[ -z "$tag" ]]; then
33+
tag=$(git describe --tags --abbrev=0)
34+
fi
35+
echo "Set tag to $tag"
36+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
37+
echo "GIT_VERSION=$tag" >> "$GITHUB_ENV"
38+
- name: Determine latest revision
39+
id: get_revision
40+
run: |
41+
set -e
42+
revision="${{ github.event.inputs.deb_revision }}"
43+
if [[ -z "$revision" ]]; then
44+
current=$(curl -s https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${GIT_VERSION} | jq -r ".assets[].name" | grep "camera-streamer-raspi.*_armhf.deb" | cut -d "_" -f 2 | cut -d "-" -f 2 | sort -nr | head -n1)
45+
echo "Found current revision $current"
46+
revision=$(expr $current + 1)
47+
fi
48+
echo "Set revision to $revision"
49+
echo "revision=$revision" >> "$GITHUB_OUTPUT"
50+
51+
build:
52+
runs-on: ubuntu-latest
53+
needs: vars
54+
permissions:
55+
contents: write
56+
strategy:
57+
matrix:
58+
debian_version: [bullseye]
59+
docker_arch: [amd64, arm32v7, arm64v8]
60+
build_type: [generic, raspi]
61+
exclude:
62+
- docker_arch: amd64
63+
build_type: raspi
64+
- debian_version: buster
65+
build_type: raspi
66+
steps:
67+
- name: Checkout
68+
uses: actions/checkout@v3
69+
with:
70+
fetch-depth: 0
71+
submodules: recursive
72+
ref: ${{ needs.vars.outputs.tag }}
73+
- name: Set GIT_VERSION
74+
run: echo "GIT_VERSION=$(git describe --tags)" >> $GITHUB_ENV
75+
- name: Set DEB_REVISION
76+
shell: bash
77+
run: |
78+
revision="${{ needs.vars.outputs.revision }}"
79+
if [[ -n "$revision" ]]; then
80+
echo "DEB_REVISION=${revision}" >> $GITHUB_ENV
81+
else
82+
echo "DEB_REVISION=1" >> $GITHUB_ENV
83+
fi
84+
- name: Set up QEMU
85+
uses: docker/setup-qemu-action@v2
86+
- name: Build Dockerfile
87+
run: docker build --target deb_make --tag deb_make --file .github/ci/Dockerfile --build-arg GIT_VERSION --build-arg DEB_REVISION --build-arg DOCKER_ARCH --build-arg DEBIAN_VERSION --build-arg BUILD_TYPE .
88+
env:
89+
DEBIAN_VERSION: ${{ matrix.debian_version }}
90+
DOCKER_ARCH: ${{ matrix.docker_arch }}/
91+
BUILD_TYPE: ${{ matrix.build_type }}
92+
- name: Create container
93+
run: docker create --name deb_make deb_make
94+
- name: Copy files
95+
run: 'docker cp deb_make:/deb/. deb/'
96+
- name: 'Release debian files'
97+
uses: ncipollo/release-action@v1
98+
with:
99+
tag: "${{ env.GIT_VERSION }}"
100+
artifacts: "deb/*.deb"
101+
allowUpdates: true
102+
omitBodyDuringUpdate: true
103+
omitNameDuringUpdate: true
104+
omitPrereleaseDuringUpdate: true

0 commit comments

Comments
 (0)