Skip to content

Release Version Check #6

Release Version Check

Release Version Check #6

Workflow file for this run

name: Release Version Check
on:
release:
types: [created]
jobs:
check-version:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check Tag against Version in __init__.py
id: check_version
run: |
TAG_NAME=${GITHUB_REF#refs/tags/v}
VERSION=$(grep '__version__' tmu/__init__.py | cut -d '"' -f 2)
if [ "$TAG_NAME" != "$VERSION" ]; then
echo "Release tag version '$TAG_NAME' does not match the __version__ '$VERSION' in __init__.py"
exit 1
fi
env:
GITHUB_REF: ${{ github.event.release.tag_name }}
- name: Cancel all workflow runs in the repository
if: failure()
run: |
# Fetch all workflow runs for the repo
RUNS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs" | jq '.workflow_runs[] | .id')
# Iterate over each run and cancel it
for run in $RUNS; do
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs/$run/cancel"
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Rollback Release OnError
if: failure()
uses: author/action-rollback@stable
with:
release_id: ${{ github.event.release.id }}
delete_orphan_tag: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}