Build repository release #66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build repository release | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
create: | |
tags: | |
- "v*" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
os-version: ["debian:buster", "debian:bullseye", "debian:bookworm", "ubuntu:noble", "ubuntu:jammy", "ubuntu:focal"] | |
arch: ["amd64" , "arm64"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract OS Flavor and Version | |
id: extract-os | |
run: | | |
os_version="${{ matrix.os-version }}" | |
echo "flavor=${os_version%%:*}" >> $GITHUB_ENV | |
echo "version=${os_version##*:}" >> $GITHUB_ENV | |
- uses: jtdor/build-deb-action@v1 | |
env: | |
DEB_BUILD_OPTIONS: noautodbgsym | |
with: | |
docker-image: "${{ matrix.os-version }}" | |
host-arch: "${{ matrix.arch }}" | |
setup-hook: | | |
os_version="${{ matrix.os-version }}" | |
flavor=${os_version%%:*} | |
arch="${{ matrix.arch }}" | |
if [ "$flavor" = "ubuntu" ] && [ "$arch" = "arm64" ]; then | |
# check for deb822 source format | |
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then | |
cp /etc/apt/sources.list.d/ubuntu.sources /etc/apt/sources.list.d/ubuntu-arm.sources | |
sed -i 's,[a-z]*.ubuntu.com,ports.ubuntu.com,' /etc/apt/sources.list.d/ubuntu-arm.sources | |
sed -i 's,/ubuntu/$,/ubuntu-ports/,' /etc/apt/sources.list.d/ubuntu-arm.sources | |
sed -i 's/^Components:/Architectures: arm64\nComponents:/' /etc/apt/sources.list.d/ubuntu-arm.sources | |
sed -i 's/^Components:/Architectures: amd64\nComponents:/' /etc/apt/sources.list.d/ubuntu.sources | |
else | |
cp /etc/apt/sources.list /etc/apt/sources.list.d/ubuntu-arm.list | |
sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list | |
sed -i 's,[a-z]*.ubuntu.com,ports.ubuntu.com,' /etc/apt/sources.list.d/ubuntu-arm.list | |
sed -i 's,/ubuntu/ ,/ubuntu-ports/ ,' /etc/apt/sources.list.d/ubuntu-arm.list | |
sed -i 's/^deb /deb [arch=arm64] /' /etc/apt/sources.list.d/ubuntu-arm.list | |
cat /etc/apt/sources.list /etc/apt/sources.list.d/ubuntu-arm.list | |
fi | |
fi | |
if [ "$arch" = "arm64" ]; then | |
dpkg --add-architecture arm64 | |
apt-get update | |
DEBIAN_FRONTEND=noninteractive apt-get -y install libssl-dev:arm64 tinycdb:arm64 libmilter-dev:arm64 libcdb-dev:arm64 | |
fi | |
extra-build-deps: devscripts git dpkg-cross | |
before-build-hook: "dch --local ~${{ env.version }} 'GitHub build for ${{ matrix.os-version }}'" | |
buildpackage-opts: --build=binary --no-sign -d | |
- name: Upload deb files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: "packages-${{ env.version }}-${{ matrix.arch }}" | |
path: ./debian/artifacts/* | |
merge-artefacts: | |
name: Merge all deb files to single artifact | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: debian-packages | |
uses: actions/upload-artifact/merge@v4 | |
add_release: | |
name: Add package to release | |
needs: merge-artefacts | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: merged-artifacts | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: ./*.deb | |
add_repo: | |
name: Add packages to public debian repository | |
runs-on: ubuntu-latest | |
needs: merge-artefacts | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: "merged-artifacts" | |
- name: Add releases to repo | |
uses: smeinecke/apt-repo-action@master | |
with: | |
github_token: ${{ github.token }} | |
repo_supported_arch: | | |
amd64 | |
arm64 | |
repo_supported_version: | | |
stretch | |
buster | |
bullseye | |
bookworm | |
noble | |
jammy | |
focal | |
file: | | |
*.deb | |
version_by_filename: true | |
private_key: ${{ secrets.APT_SIGNING_KEY }} | |
public_key: ${{ vars.APT_PUBLIC_KEY }} | |
key_passphrase: "" | |
skip_duplicates: true |