From 52c408ce3453db7ff7797f3cd5b8710c12de6050 Mon Sep 17 00:00:00 2001 From: tommie Date: Mon, 20 Mar 2023 17:33:34 +0100 Subject: [PATCH] First checks for new releases. It's annoying that reprepro includedeb fails if there is an existing release. If we're fixing that, we might as well not build if there is no need. --- .github/workflows/main.yml | 50 +++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3f70fa8..55b8256 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,19 +13,21 @@ on: workflow_dispatch: jobs: - build-deb: - name: Build DEB Packages + check-upstream: + name: Check for a new releases upstream runs-on: ubuntu-latest outputs: - innernet_release: ${{ steps.download-release.outputs.innernet_release }} + innernet_release: ${{ steps.check-latest-release.outputs.innernet_release }} + tarball_url: ${{ steps.check-latest-release.outputs.tarball_url }} + new_release_exists: ${{ steps.check-repo-release.outputs.new_release_exists }} steps: - name: Install Distro Dependencies - run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes dpkg-dev jq liblzma-dev + run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes jq liblzma-dev reprepro - - name: Download Latest Release - id: download-release + - name: Check Latest Release + id: check-latest-release run: | wget -O- \ -H'Accept: application/json' \ @@ -34,11 +36,36 @@ jobs: | ( read release tarball_url echo "innernet_release=$release" >>"$GITHUB_OUTPUT" - wget -O- "$tarball_url" | tar xz - mv tonarino-innernet-*/* . - rm -fr tonarino-innernet-* + echo "tarball_url=$tarball_url" >>"$GITHUB_OUTPUT" ) + - name: Check Repo Release + id: check-repo-release + run: | + indexed=$(reprepro --list-format '${version}\n' listmatched unstable innernet) + if [ "x$indexed" = "x${{ steps.check-latest-release.outputs.innernet_release }}" ]; then + echo "new_release_exists=false" >>"$GITHUB_OUTPUT" + else + echo "new_release_exists=true" >>"$GITHUB_OUTPUT" + fi + + build-deb: + name: Build DEB Packages + runs-on: ubuntu-latest + needs: [check-upstream] + if: ${{ needs.check-upstream.outputs.new_release_exists == 'true' }} + + steps: + - name: Install Distro Dependencies + run: sudo env DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes dpkg-dev liblzma-dev + + - name: Download Latest Release + id: download-release + run: | + wget -O- "${{ needs.check-upstream.outputs.tarball_url }}" | tar xz + mv tonarino-innernet-*/* . + rm -fr tonarino-innernet-* + - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -73,7 +100,8 @@ jobs: release: runs-on: ubuntu-latest - needs: [build-deb] + needs: [check-upstream, build-deb] + if: ${{ needs.check-upstream.outputs.new_release_exists == 'true' }} steps: - name: Install Distro Dependencies @@ -124,7 +152,7 @@ jobs: git \ -c 'user.email=41898282+github-actions[bot]@users.noreply.github.com' \ -c 'user.name=github-actions[bot]' \ - commit -m "Included release tonarino/innernet@${{ needs.build-deb.outputs.innernet_release }}." + commit -m "Included release tonarino/innernet@${{ needs.check-upstream.outputs.innernet_release }}." else echo 'No updates to commit.' fi