Build #1
This file contains hidden or 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 | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| actions: write | |
| packages: write | |
| contents: write | |
| steps: | |
| - | |
| name: Get remote package data | |
| run: | | |
| set -e -o pipefail | |
| latest_tag=""; | |
| while read -r v; do { | |
| [ -z "$latest_tag" ] || dpkg --compare-versions "$v" gt "$latest_tag"; } && latest_tag="$v" | |
| done < <(curl -fsSL http://download.proxmox.com/debian/pmg/dists/trixie/pmg-no-subscription/binary-amd64/Packages.gz | \ | |
| gzip -dc | awk '/^Package: pmg-api$/ {f=1; next} f && /^Version:/ {print $2; f=0}') | |
| latest_tag="${latest_tag%-*}" | |
| echo "Found tag: \"${latest_tag}\"" | |
| major="${latest_tag%%.*}" | |
| minor="${latest_tag#*.}" | |
| minor="${minor%%.*}" | |
| echo "latest_tag=$latest_tag" >> $GITHUB_ENV | |
| echo "latest_minor=$major.$minor" >> $GITHUB_ENV | |
| echo "latest_major=$major" >> $GITHUB_ENV | |
| - | |
| name: Check if the tag exists locally | |
| uses: action-pack/tag-exists@v1 | |
| id: checkTag | |
| with: | |
| tag: '${{ env.latest_tag }}' | |
| - | |
| name: Finish when found | |
| run: | | |
| #!/bin/bash | |
| val="${{ steps.checkTag.outputs.exists }}" | |
| echo "exists=${val}" >> $GITHUB_ENV | |
| - | |
| name: Free up disk space | |
| if: env.exists == 'false' | |
| run: | | |
| sudo rm -rf /usr/local/.ghcup | |
| sudo rm -rf /usr/local/lib/android | |
| sudo rm -rf /usr/local/lib/node_modules | |
| sudo rm -rf /usr/share/dotnet | |
| sudo rm -rf /usr/share/swift | |
| df -h | |
| - | |
| name: Checkout | |
| if: env.exists == 'false' | |
| uses: actions/checkout@v7 | |
| with: | |
| persist-credentials: false | |
| - | |
| name: Set up Docker Buildx | |
| if: env.exists == 'false' | |
| uses: docker/setup-buildx-action@v4 | |
| - | |
| name: Build packages | |
| if: env.exists == 'false' | |
| run: | | |
| baseimage="debian:trixie-slim" | |
| echo "DEB_DIST=Debian/Trixie" >> $GITHUB_ENV | |
| docker buildx build -o packages --build-arg buildoptions="github=${{ env.latest_tag }}" --build-arg baseimage=${baseimage} --platform=linux/arm64 -f Dockerfile . | |
| sudo apt -y install apt-listchanges | |
| apt-listchanges --latest=1 -f text packages/pmg-api_*.deb | | |
| sed -e '/^\(apt-listchanges.*\|[-]\+\)$/d' >> .github/PREBUILD.md | |
| echo "DEB_VERSION=$(dpkg --info packages/pmg-api_*.deb | sed -n '/Version/ s/[^:]\+: //p')" >> "$GITHUB_ENV" | |
| echo "DEB_VERSION_UPSTREAM=$(dpkg --info packages/pmg-api_*.deb | sed -n '/Version/ s/[^:]\+: \([0-9.]\+\)-\?[0-9]*/\1/p')" >> "$GITHUB_ENV" | |
| - | |
| name: Test packages | |
| if: env.exists == 'false' | |
| run: | | |
| baseimage="debian:trixie-slim" | |
| docker buildx build --build-arg baseimage=${baseimage} --platform linux/arm64 -f .github/Dockerfile.installtest . | |
| - | |
| name: Release packages | |
| if: env.exists == 'false' | |
| run: | | |
| gh release create "${{ env.latest_tag }}" \ | |
| --title "v${{ env.latest_tag }}" \ | |
| --notes-file .github/PREBUILD.md \ | |
| --latest=true \ | |
| packages/*.deb | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - | |
| name: Send mail | |
| if: env.exists == 'false' | |
| uses: action-pack/send-mail@v1 | |
| with: | |
| to: ${{secrets.MAILTO}} | |
| from: Github Actions <${{secrets.MAILTO}}> | |
| connection_url: ${{secrets.MAIL_CONNECTION}} | |
| subject: Build of ${{ github.event.repository.name }} v${{ env.latest_tag }} completed | |
| body: | | |
| The build job of ${{ github.event.repository.name }} v${{ env.latest_tag }} was completed successfully! | |
| See https://github.com/${{ github.repository }}/actions for more information. |