owntone-apt/.github/workflows/create_dpkg.yml

158 lines
7.3 KiB
YAML

name: Create Debian packages
on:
workflow_dispatch:
inputs:
raspbian-buster-armhf:
type: boolean
raspbian-bullseye-armhf:
type: boolean
raspbian-bookworm-armhf:
type: boolean
raspberrypi-bullseye-arm64:
type: boolean
raspberrypi-bookworm-arm64:
type: boolean
debian-bullseye-amd64:
type: boolean
debian-bookworm-amd64:
type: boolean
schedule:
# Rebuild once a month. Could be 0 0 1, but Github servers are probably
# quite busy at that time.
- cron: '7 7 24 * *'
# Use FLAGS to only build sources for one of the packages. The below could also
# be imported from files, but that would add a checkout step, plus makes it more
# important to support multiline json as per:
# https://github.community/t/set-output-truncates-multiline-strings/16852
env:
raspbian-buster-armhf: '{"image":"raspbian-buster-armhf","OS":"raspbian","DIST":"buster","ARCH":"armhf","FLAGS":""}'
raspbian-bullseye-armhf: '{"image":"raspbian-bullseye-armhf","OS":"raspbian","DIST":"bullseye","ARCH":"armhf","FLAGS":"-- --binary-arch"}'
raspbian-bookworm-armhf: '{"image":"raspbian-bookworm-armhf","OS":"raspbian","DIST":"bookworm","ARCH":"armhf","FLAGS":"-- --binary-arch"}'
raspberrypi-bullseye-arm64: '{"image":"raspberrypi-bullseye-arm64","OS":"raspberrypi","DIST":"bullseye","ARCH":"arm64","FLAGS":"-- --binary-arch"}'
raspberrypi-bookworm-arm64: '{"image":"raspberrypi-bookworm-arm64","OS":"raspberrypi","DIST":"bookworm","ARCH":"arm64","FLAGS":"-- --binary-arch"}'
debian-bullseye-amd64: '{"image":"debian-bullseye-amd64","OS":"debian","DIST":"bullseye","ARCH":"amd64","FLAGS":"-- --binary-arch"}'
debian-bookworm-amd64: '{"image":"debian-bookworm-amd64","OS":"debian","DIST":"bookworm","ARCH":"amd64","FLAGS":"-- --binary-arch"}'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
env:
PKGCONF: pkgconf
BUILD_raspbian-buster-armhf: ${{ github.event.inputs.raspbian-buster-armhf || 'true' }}
BUILD_raspbian-bullseye-armhf: ${{ github.event.inputs.raspbian-bullseye-armhf || 'true' }}
BUILD_raspbian-bookworm-armhf: ${{ github.event.inputs.raspbian-bookworm-armhf || 'true' }}
BUILD_raspberrypi-bullseye-arm64: ${{ github.event.inputs.raspberrypi-bullseye-arm64 || 'true' }}
BUILD_raspberrypi-bookworm-arm64: ${{ github.event.inputs.raspberrypi-bookworm-arm64 || 'true' }}
BUILD_debian-bullseye-amd64: ${{ github.event.inputs.debian-bullseye-amd64 || 'true' }}
BUILD_debian-bookworm-amd64: ${{ github.event.inputs.debian-bookworm-amd64 || 'true' }}
steps:
- name: Add raspbian-buster-armhf
if: ${{ env.BUILD_raspbian-buster-armhf == 'true' }}
run: echo -n '${{ env.raspbian-buster-armhf }},' >> $PKGCONF
- name: Add raspbian-bullseye-armhf
if: ${{ env.BUILD_raspbian-bullseye-armhf == 'true' }}
run: echo -n '${{ env.raspbian-bullseye-armhf }},' >> $PKGCONF
- name: Add raspbian-bookworm-armhf
if: ${{ env.BUILD_raspbian-bookworm-armhf == 'true' }}
run: echo -n '${{ env.raspbian-bookworm-armhf }},' >> $PKGCONF
- name: Add raspberrypi-bullseye-arm64
if: ${{ env.BUILD_raspberrypi-bullseye-arm64 == 'true' }}
run: echo -n '${{ env.raspberrypi-bullseye-arm64 }},' >> $PKGCONF
- name: Add raspberrypi-bookworm-arm64
if: ${{ env.BUILD_raspberrypi-bookworm-arm64 == 'true' }}
run: echo -n '${{ env.raspberrypi-bookworm-arm64 }},' >> $PKGCONF
- name: Add debian-bullseye-amd64
if: ${{ env.BUILD_debian-bullseye-amd64 == 'true' }}
run: echo -n '${{ env.debian-bullseye-amd64 }},' >> $PKGCONF
- name: Add debian-bookworm-amd64
if: ${{ env.BUILD_debian-bookworm-amd64 == 'true' }}
run: echo -n '${{ env.debian-bookworm-amd64 }},' >> $PKGCONF
- name: Set matrix
id: set-matrix
run: |
test -f $PKGCONF || { echo "No packages selected"; exit 1; }
echo -e "`cat $PKGCONF`\n"
echo "matrix={\"include\":[`cat $PKGCONF`]}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Load package info into environment
run: |
cat ./pkginfo >> $GITHUB_ENV
- name: Prepare directories
run: |
mkdir dl
mkdir build_dir
mkdir cache
# dh-make and devscripts are only used for the package build
- name: Install pbuilder, Debian tools, keyrings
run: |
sudo apt-get update
sudo apt-get install -yq pbuilder qemu-user-static debian-archive-keyring devscripts dh-make
wget -O dl/raspbian-archive-keyring.deb http://archive.raspbian.org/raspbian/pool/main/r/raspbian-archive-keyring/raspbian-archive-keyring_20120528.2_all.deb
sudo dpkg -i dl/raspbian-archive-keyring.deb
wget -O dl/raspberrypi-archive-keyring.deb http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-archive-keyring/raspberrypi-archive-keyring_2016.10.31_all.deb
sudo dpkg -i dl/raspberrypi-archive-keyring.deb
- name: Cache pbuilder image
id: cache-image
uses: actions/cache@v4
with:
path: cache/${{ matrix.image }}-base.tgz
key: ${{ matrix.image }}
- name: Restore image from cache
if: steps.cache-image.outputs.cache-hit == 'true'
run: |
sudo cp cache/${{ matrix.image }}-base.tgz /var/cache/pbuilder/
- name: Or create pbuilder image
if: steps.cache-image.outputs.cache-hit != 'true'
run: |
sudo OS=${{ matrix.OS }} DIST=${{ matrix.DIST }} ARCH=${{ matrix.ARCH }} pbuilder create --configfile pbuilderrc
cp /var/cache/pbuilder/${{ matrix.image }}-base.tgz cache/
- name: Download and unpack OwnTone
run: |
wget -O build_dir/${{ env.PKGNAME }}_${{ env.VER }}.orig.tar.gz https://github.com/${{ env.OWNER }}/${{ env.REPOSITORY }}/archive/${{ env.COMMIT }}.tar.gz
tar xzf build_dir/${{ env.PKGNAME }}_${{ env.VER }}.orig.tar.gz --directory build_dir
mv build_dir/${{ env.REPOSITORY }}-$COMMIT build_dir/${{ env.PKGNAME }}-${{ env.VER }}
cp -a ${{ env.REPOSITORY }}/debian build_dir/${{ env.PKGNAME }}-${{ env.VER }}
# The below uses a method of creating changelog and setting versions that
# isn't very kosher. I don't know how to use the proper method while still
# creating different packages for different distributions that can be
# served from one repo.
- name: Build OwnTone package
working-directory: build_dir/${{ env.PKGNAME }}-${{ env.VER }}
run: |
dch --create --package ${{ env.PKGNAME }} --newversion ${{ env.VER }}-${{ env.DEB }}+${{ matrix.DIST }} --distribution ${{ matrix.DIST }} --force-distribution "Dummy changelog @commit ${{ env.COMMIT }}"
sudo OS=${{ matrix.OS }} DIST=${{ matrix.DIST }} ARCH=${{ matrix.ARCH }} DEB_BUILD_OPTIONS="parallel=$(nproc) nocheck" pdebuild --configfile ../../pbuilderrc ${{ matrix.FLAGS }}
rm debian/changelog
- name: Upload dpkg
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.image }}
path: /var/cache/pbuilder/result/${{ matrix.image }}