From 45c2dd0358a934b2e14f5539f19dd26b953f92c7 Mon Sep 17 00:00:00 2001 From: Julian Raufelder Date: Tue, 11 Oct 2022 12:42:59 +0200 Subject: [PATCH] Validate release check precondition in separate job --- .github/workflows/build.yml | 58 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83df47560..c0376341e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,11 +12,42 @@ defaults: run: shell: bash -jobs: +jobs: + release-check-precondition: + name: Validate pushed commit to release/hotfix branch or pushed tag + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/hotfix/') || startsWith(github.ref, 'refs/heads/release/') + steps: + - uses: actions/checkout@v2 + - id: validate-pom-version + name: Validate POM version + run: | + if [[ $GITHUB_REF =~ refs/heads/(hotfix|release)/[0-9]+\.[0-9]+\.[0-9]+.* ]]; then + SEM_VER_STR=${GITHUB_REF##*/} + elif [[ $GITHUB_REF =~ refs/tags/[0-9]+\.[0-9]+\.[0-9]+.* ]]; then + SEM_VER_STR=${GITHUB_REF##*/} + else + echo "Failed to parse version" + exit 1 + fi + + if [[ ${SEM_VER_STR} == `mvn help:evaluate -Dexpression=project.version -q -DforceStdout` ]]; then + echo "::set-output name=semVerStr::${SEM_VER_STR}" + else + echo "Version not set in POM" + exit 1 + fi + - name: Validate release in org.cryptomator.Cryptomator.metainfo.xml file + run: | + if ! grep -q "" dist/linux/common/org.cryptomator.Cryptomator.metainfo.xml; then + echo "Release not set in dist/linux/common/org.cryptomator.Cryptomator.metainfo.xml" + exit 1 + fi test: name: Compile and Test + needs: release-check-precondition runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" + if: "always() && (needs.release-check-precondition.result=='success' || needs.release-check-precondition.result=='skipped') && !contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')" steps: - uses: actions/checkout@v2 - uses: actions/setup-java@v2 @@ -43,29 +74,6 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Validate POM version - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/hotfix/') || startsWith(github.ref, 'refs/heads/release/') - run: | - if [[ $GITHUB_REF =~ refs/heads/(hotfix|release)/[0-9]+\.[0-9]+\.[0-9]+.* ]]; then - SEM_VER_STR=${GITHUB_REF##*/} - elif [[ $GITHUB_REF =~ refs/tags/[0-9]+\.[0-9]+\.[0-9]+.* ]]; then - SEM_VER_STR=${GITHUB_REF##*/} - else - echo "Failed to parse version" - exit 1 - fi - - if ![[ SEM_VER_STR = `mvn help:evaluate -Dexpression=project.version -q -DforceStdout` ]]; then - echo "Version not set in POM" - exit 1 - fi - - name: Validate release in org.cryptomator.Cryptomator.metainfo.xml file - if: startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/hotfix/') || startsWith(github.ref, 'refs/heads/release/') - run: | - if ![[ grep "" dist/linux/common/org.cryptomator.Cryptomator.metainfo.xml ]]; then - echo "Release not set in dist/linux/common/org.cryptomator.Cryptomator.metainfo.xml" - exit 1 - fi - name: Sign source tarball with key 615D449FE6E6A235 if: startsWith(github.ref, 'refs/tags/') run: |