From 758b03de363c9fd1979127a6b0505cf9903027e7 Mon Sep 17 00:00:00 2001 From: ronahk <74967920+ronahk@users.noreply.github.com> Date: Wed, 9 Nov 2022 15:35:28 +0200 Subject: [PATCH] Validate tag name matches plugin version in gh actions (#80) * validate that tag name matches plugin version in gh actions * fail workflow if tag name doesn't match plugin version --- .github/workflows/release.yaml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index bd87b6d..940dcdd 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -6,9 +6,33 @@ on: - "*" jobs: - release: + pre_release: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Get plugin version + id: get_plugin_version + run: echo "PLUGIN_VERSION=$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)" >> $GITHUB_OUTPUT + - name: Get tag name + id: get_tag_name + run: echo "TAG_NAME=$(echo ${{ github.ref_name }} | cut -d 'v' -f2)" >> $GITHUB_OUTPUT + outputs: + plugin_version: ${{ steps.get_plugin_version.outputs.PLUGIN_VERSION }} + tag_name: ${{ steps.get_tag_name.outputs.TAG_NAME }} + + release: + needs: pre_release + runs-on: ubuntu-latest + steps: + - name: Plugin version/Tag name Check + if: needs.pre_release.outputs.release_tag != needs.pre_release.outputs.plugin_version + uses: actions/github-script@v3 + with: + script: | + core.setFailed('Plugin version and tag name are not equivalent!') - name: Checkout uses: actions/checkout@v3 with: