From 49c20c6cc1e14f142660553b04d969edaf989212 Mon Sep 17 00:00:00 2001 From: tytan652 Date: Thu, 7 Jul 2022 21:37:19 +0200 Subject: [PATCH] CI: Fix Flatpak releases Add a job where the tag is checked if it is valid, it also checks if the release should be published to Flathub beta and/or Flathub by dynamically setting the matrix. --- .github/workflows/flatpak.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/flatpak.yml b/.github/workflows/flatpak.yml index 11dd6587e..dab3a3f5e 100644 --- a/.github/workflows/flatpak.yml +++ b/.github/workflows/flatpak.yml @@ -18,10 +18,35 @@ env: YOUTUBE_SECRET_HASH: ${{ secrets.YOUTUBE_SECRET_HASH }} jobs: + check_tag: + name: Check release tag + runs-on: [ubuntu-latest] + outputs: + valid_tag: ${{ steps.check_tag.outputs.valid_tag }} + matrix: ${{ steps.check_tag.outputs.matrix }} + steps: + - name: Check the tag + id: check_tag + run: | + shopt -s extglob + + case ${GITHUB_REF##*/} in + +([0-9]).+([0-9]).+([0-9]) ) + echo '::set-output name=valid_tag::${{ toJSON(true) }}' + echo '::set-output name=matrix::["beta", "stable"]' + ;; + +([0-9]).+([0-9]).+([0-9])-@(beta|rc) ) + echo '::set-output name=valid_tag::${{ toJSON(true) }}' + echo '::set-output name=matrix::["beta"]' + ;; + * ) echo '::set-output name=valid_tag::${{ toJSON(false) }}' ;; + esac + publish: name: Publish to Flathub runs-on: [ubuntu-latest] - if: "${{ github.event_name == 'release' && ( matrix.branch != 'stable' || (!contains(github.ref, '-beta') && !contains(github.ref, '-rc')) ) }}" + needs: check_tag + if: fromJSON(needs.check_tag.outputs.valid_tag) env: FLATPAK_BUILD_PATH: flatpak_app/files/share container: @@ -29,7 +54,7 @@ jobs: options: --privileged strategy: matrix: - branch: [stable, beta] + branch: ${{ fromJSON(needs.check_tag.outputs.matrix) }} steps: - name: Checkout uses: actions/checkout@v3