From 2011762dbba8a90ba9b1010e9bd077ba8983f23a Mon Sep 17 00:00:00 2001 From: Marco Ebert Date: Thu, 25 Jul 2024 15:34:42 +0200 Subject: [PATCH] GitHub: Rework release action. --- .github/workflows/releases.yaml | 76 +++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/releases.yaml diff --git a/.github/workflows/releases.yaml b/.github/workflows/releases.yaml new file mode 100644 index 000000000..ad6008717 --- /dev/null +++ b/.github/workflows/releases.yaml @@ -0,0 +1,76 @@ +name: Releases + +on: + push: + branches: + - main + - master + # Remove when ready. + - liljx + paths: + - "*/v*.*.*" + # Remove when ready. + - .github/workflows/releases.yaml + +jobs: + get-releases: + name: Get releases + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Get releases + id: get-releases + run: echo releases="$(jq --null-input --args '$ARGS.positional' --compact-output -- {azure,capa}/v*.*.*)" >> "${GITHUB_OUTPUT}" + - name: Print releases + env: + releases: ${{ steps.get-releases.outputs.releases }} + run: echo "${releases}" + + outputs: + releases: ${{ steps.get-releases.outputs.releases }} + + create-release: + name: Create release + runs-on: ubuntu-latest + needs: get-releases + + strategy: + matrix: + release: ${{ fromJSON(needs.get-releases.outputs.releases) }} + + steps: + - name: Print release + env: + release: ${{ matrix.release }} + run: echo "${release}" + - name: Split release + id: split-release + env: + release: ${{ matrix.release }} + run: | + # Get provider & version. + provider="${release%/v*.*.*}" + version="${release#${provider}/}" + + # Switch release. + case "${provider}" in + capa) + provider="aws" + ;; + esac + + # Store provider & version. + echo provider="${provider}" >> "${GITHUB_OUTPUT}" + echo version="${version}" >> "${GITHUB_OUTPUT}" + - name: Print provider & version + env: + provider: ${{ steps.split-release.outputs.provider }} + version: ${{ steps.split-release.outputs.version }} + run: echo "${provider} | ${version}" + - name: Check tag + env: + provider: ${{ steps.split-release.outputs.provider }} + version: ${{ steps.split-release.outputs.version }} + run: git tag --list "${provider}/${version}"