Skip to content

Commit

Permalink
GitHub: Rework release action.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gacko committed Jul 29, 2024
1 parent 3f37d25 commit 682ee6c
Showing 1 changed file with 96 additions and 0 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
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: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- 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: Get tag
id: get-tag
env:
provider: ${{ steps.split-release.outputs.provider }}
version: ${{ steps.split-release.outputs.version }}
run: |
# Define tag.
tag="${provider}/${version}"
# Check tag.
[ -z "$(git tag --list "${tag}")" ] && exists=true || exists=false
# Store tag & exists.
echo tag="${tag}" >> "${GITHUB_OUTPUT}"
echo exists="${exists}" >> "${GITHUB_OUTPUT}"
- name: Create tag
if: ${{ steps.get-tag.outputs.exists }} == false
env:
tag: ${{ steps.get-tag.outputs.tag }}
run: echo "${tag}"

0 comments on commit 682ee6c

Please sign in to comment.