From 713bbb550a963874efd77c0d50b6240b8b6452e2 Mon Sep 17 00:00:00 2001 From: Neshura Date: Wed, 7 Aug 2024 19:48:40 +0200 Subject: [PATCH] CI Cross-Job Var Fix Attempt --- .forgejo/workflows/build+release.yml | 12 ++++++++---- .forgejo/workflows/pull-requests.yml | 25 +++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.forgejo/workflows/build+release.yml b/.forgejo/workflows/build+release.yml index 81de150..db97083 100644 --- a/.forgejo/workflows/build+release.yml +++ b/.forgejo/workflows/build+release.yml @@ -47,6 +47,10 @@ jobs: if: success() runs-on: docker container: forgejo.neshweb.net/ci-docker-images/rust-node:latest + outputs: + DEBIAN_NAME: ${{ steps.deb_bundle.outputs.debian_name }} + DEBIAN_REV: ${{ steps.deb_bundle.outputs.debian_rev }} + DEBIAN_REF: ${{ steps.deb_bundle.outputs.debian_ref }} steps: - name: Checking Out Repository Code @@ -109,20 +113,20 @@ jobs: name: Upload Debian Package to staging run: | echo 'curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \ - --upload-file release_blobs/${{ steps.deb_bundle.outputs.debian_name }}_'${{ steps.deb_bundle.outputs.debian_ref }}${{ steps.deb_bundle.outputs.debian_rev }}'_amd64.deb \ + --upload-file release_blobs/${{ needs.build.outputs.debian_name }}_'${{ needs.build.outputs.debian_ref }}${{ needs.build.outputs.debian_rev }}'_amd64.deb \ ${{ env.GITHUB_API_URL }}/packages/${{ env.GITHUB_REPOSITORY_OWNER }}/debian/pool/bookworm/staging/upload' curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \ - --upload-file release_blobs/${{ steps.deb_bundle.outputs.debian_name }}_${{ steps.deb_bundle.outputs.debian_ref }}${{ steps.deb_bundle.outputs.debian_rev }}_amd64.deb \ + --upload-file release_blobs/${{ needs.build.outputs.debian_name }}_${{ needs.build.outputs.debian_ref }}${{ needs.build.outputs.debian_rev }}_amd64.deb \ ${{ env.GITHUB_API_URL }}/packages/${{ env.GITHUB_REPOSITORY_OWNER }}/debian/pool/bookworm/staging/upload - name: Upload Debian Package to main if: (! contains(github.ref_name, '-rc')) run: | echo 'curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \ - --upload-file release_blobs/${{ steps.deb_bundle.outputs.debian_name }}_'${{ steps.deb_bundle.outputs.debian_ref }}${{ steps.deb_bundle.outputs.debian_rev }}'_amd64.deb \ + --upload-file release_blobs/${{ needs.build.outputs.debian_name }}_'${{ needs.build.outputs.debian_ref }}${{ needs.build.outputs.debian_rev }}'_amd64.deb \ ${{ env.GITHUB_API_URL }}/packages/${{ env.GITHUB_REPOSITORY_OWNER }}/debian/pool/bookworm/main/upload' curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \ - --upload-file release_blobs/${{ steps.deb_bundle.outputs.debian_name }}_${{ steps.deb_bundle.outputs.debian_ref }}${{ steps.deb_bundle.outputs.debian_rev }}_amd64.deb \ + --upload-file release_blobs/${{ needs.build.outputs.debian_name }}_${{ needs.build.outputs.debian_ref }}${{ needs.build.outputs.debian_rev }}_amd64.deb \ ${{ env.GITHUB_API_URL }}/packages/${{ env.GITHUB_REPOSITORY_OWNER }}/debian/pool/bookworm/main/upload create-release: diff --git a/.forgejo/workflows/pull-requests.yml b/.forgejo/workflows/pull-requests.yml index d8db6cd..c1f4270 100644 --- a/.forgejo/workflows/pull-requests.yml +++ b/.forgejo/workflows/pull-requests.yml @@ -37,6 +37,10 @@ jobs: if: success() runs-on: docker container: forgejo.neshweb.net/ci-docker-images/rust-node:latest + outputs: + DEBIAN_NAME: ${{ steps.deb_bundle.outputs.debian_name }} + DEBIAN_REV: ${{ steps.deb_bundle.outputs.debian_rev }} + DEBIAN_REF: ${{ steps.deb_bundle.outputs.debian_ref }} steps: - name: Checking Out Repository Code @@ -51,10 +55,15 @@ jobs: mv target/release/${{ github.event.repository.name }} dist/${{ github.event.repository.name }}-linux-amd64 - name: Bundle .deb package + id: deb_bundle run: | cargo deb - DEBIAN_REF=$(cat Cargo.toml | grep -E "(^|\|)version =" | cut -f2- -d= | tr -d \" | tr -d " " | tr - \~) + DEBIAN_REF=$(echo ${{ github.ref_name }} | tr - \~) + echo "debian_ref=$DEBIAN_REF" >> ${{ env.GITHUB_OUTPUT }} DEBIAN_REV=-$(cat Cargo.toml | grep -E "(^|\|)revision =" | cut -f2- -d= | tr -d \" | tr -d " ") + echo "debian_rev=$DEBIAN_REV" >> ${{ env.GITHUB_OUTPUT }} + DEBIAN_NAME=-$(cat Cargo.toml | grep -E "(^|\|)name =" | cut -f2- -d= | tr -d \" | tr -d " ") + echo "debian_name=$DEBIAN_NAME" >> ${{ env.GITHUB_OUTPUT }} mv target/debian/${{ DEBIAN_NAME }}_${{ DEBIAN_REF }}${{ DEBIAN_REV }}_amd64.deb dist/${{ DEBIAN_NAME }}_${{ DEBIAN_REF }}${{ DEBIAN_REV }}_amd64.deb - name: Uploading Build Artifact @@ -62,4 +71,16 @@ jobs: with: name: release_blobs path: dist - if-no-files-found: error \ No newline at end of file + if-no-files-found: error + + test-env: + needs: build + if: success() + runs-on: docker + steps: + - + name: Test Debian Variables + run: | + test ${{ needs.build.outputs.debian_name }} = $(echo ${{ github.ref_name }} | tr - \~) + test ${{ needs.build.outputs.debian_ref }} = $(cat Cargo.toml | grep -E "(^|\|)revision =" | cut -f2- -d= | tr -d \" | tr -d " ") + test ${{ needs.build.outputs.debian_rev }} = $(cat Cargo.toml | grep -E "(^|\|)name =" | cut -f2- -d= | tr -d \" | tr -d " ")