name: Build deb packages and push to Ubuntu PPA on: workflow_dispatch: inputs: Install: description: 'Check install only from PPA' default: false type: boolean Runner: description: 'Select runner image' required: true default: 'ubuntu-22.04' type: choice options: - 'ubuntu-24.04' # noble - 'ubuntu-22.04' # jammy Distro: description: 'Ubuntu distro name for build' required: true default: 'jammy' type: choice options: - 'resolute' # 26.04 - 'questing' # 25.10 - 'noble' # 24.04 - 'jammy' # 22.04 - 'focal' # 20.04 - 'bionic' # 18.04 - 'xenial' # 16.04 - 'trusty' # 14.04 Version: description: 'Version for build' required: false default: '' # 0.8.4 -> 0.8.4.1 -> 0.8.4.2 Push: description: 'Publish to PPA' default: false type: boolean jobs: test: name: Build deb package and push to PPA runs-on: ${{ github.event.inputs.Runner }} steps: - name: Checkout repository (main branch and 1 last commits) uses: actions/checkout@v6 with: fetch-depth: 1 ref: main - name: Check install package from PPA if: ${{ github.event.inputs.Install == 'true' }} run: | sudo add-apt-repository -y ppa:lifailon/lazyjournal sudo apt update apt-cache policy lazyjournal sudo apt install -y lazyjournal lazyjournal -v sudo apt remove -y lazyjournal - name: Install Go if: ${{ github.event.inputs.Install != 'true' }} run: | sudo apt-get update sudo apt-get install -y golang-1.23-go /usr/lib/go-1.23/bin/go version - name: Install dependencies for build deb package if: ${{ github.event.inputs.Install != 'true' }} run: | sudo apt-get install -y \ devscripts \ debhelper \ dh-golang \ dh-make-golang \ dput \ golang-golang-x-text-dev \ golang-gopkg-yaml.v3-dev - name: Import GPG key if: ${{ github.event.inputs.Install != 'true' }} uses: crazy-max/ghaction-import-gpg@v6 with: gpg_private_key: ${{ secrets.PPA_GPG_PRIVATE_KEY }} - name: Build deb package and publish to Launchpad PPA if: ${{ github.event.inputs.Install != 'true' }} env: DEB_FULLNAME: "lifailon" DEB_EMAIL: ${{ secrets.PPA_EMAIL }} DISTRO: ${{ github.event.inputs.Distro }} APP_VERSION: ${{ github.event.inputs.Version }} run: | export PATH="/usr/lib/go-1.23/bin:$PATH" export GOTOOLCHAIN=local export DEBFULLNAME="$DEB_FULLNAME" export DEBEMAIL="$DEB_EMAIL" echo -e "\n\033[33m>>> Debian template generation\033[0m\n" dh-make-golang make github.com/Lifailon/lazyjournal cd lazyjournal echo -e "\n\033[33m>>> Download dependencies for offline build\033[0m\n" go mod vendor VERSION=$(ls ../*.orig.tar.gz | sed -E 's/.*_([0-9.]+)\.orig\.tar\.gz/\1/') rm ../*.orig.tar.gz tar --exclude-vcs -C .. -czf ../lazyjournal_$VERSION.orig.tar.gz lazyjournal sed -i '1a export GOFLAGS=-mod=vendor' debian/rules echo -e "\n\033[33m>>> Update go version\033[0m\n" sed -i 's/golang-any/golang-1.23-go/' debian/control sed -i '1a export PATH := /usr/lib/go-1.23/bin:$(PATH)' debian/rules sed -i '1a export GOTOOLCHAIN := local' debian/rules echo -e "\n\033[33m>>> Update debian control\033[0m\n" sed -i 's/Section: TODO/Section: utils/' debian/control sed -i -E 's/Architecture:.+/Architecture: any/' debian/control echo -e "\n\033[33m>>> Skip go test and dwz in build\033[0m\n" # export DEB_BUILD_OPTIONS=nocheck printf "\noverride_dh_auto_test:\n\t:\n" >> debian/rules printf "\noverride_dh_dwz:\n\t:\n" >> debian/rules echo -e "\n\033[33m>>> Rules\033[0m\n" cat debian/rules echo -e "\n\033[33m>>> Update distro name in changelog\033[0m\n" sed -i "1s/)[[:space:]]\+[^;]\+;/) $DISTRO;/" debian/changelog sed -i 's/(Closes: TODO)//' debian/changelog if [ -n "$APP_VERSION" ]; then echo -e "\n\033[33m>>> Update version in changelog\033[0m\n" VERSION=$(cat debian/changelog | head -n 1 | sed -E "s/.+\(//" | sed -E "s/\).+//" | sed -E "s/-[0-9]+//") sed -i -E "s/$VERSION-/$APP_VERSION-/" debian/changelog mv ../lazyjournal_$VERSION.orig.tar.gz ../lazyjournal_$APP_VERSION.orig.tar.gz echo -e "\n\033[33m>>> Changelog\033[0m\n" cat debian/changelog fi echo -e "\n\033[33m>>> Check build\033[0m\n" dpkg-buildpackage -us -uc -b echo -e "\n\033[33m>>> Build changes\033[0m\n" rm -f ../*.upload ../*.changes debuild -S -sa -k"$DEBEMAIL" cd .. ls *.changes - name: Push to PPA if: ${{ github.event.inputs.Install != 'true' && github.event.inputs.Push == 'true' }} run: | dput ppa:lifailon/lazyjournal ../*.changes