Skip to content

Commit

Permalink
chore: define check ensuring migration guide is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinBettati committed Apr 18, 2024
1 parent a535375 commit 22cfb52
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,21 @@ jobs:
echo "runs_tests=$(if [ '${{ inputs.skip_tests }}' = 'true' ]; then echo 'false'; else echo 'true'; fi)"
} >> "$GITHUB_OUTPUT"
validate-version-input:
validate-inputs:
runs-on: ubuntu-latest
steps:
- name: Validation of version format
run: |
echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$'
- name: Checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
with:
ref: ${{ inputs.use_existing_tag == 'true' && inputs.version_number || 'master' }}
- name: Check for Upgrade Guide
run: './scripts/check-upgrade-guide-exists.sh ${{inputs.version_number}}'

update-examples-reference-in-docs:
needs: [ release-config, validate-version-input ]
needs: [ release-config, validate-inputs ]
if: >-
!cancelled()
&& !contains(needs.*.result, 'failure')
Expand All @@ -58,7 +64,7 @@ jobs:
passphrase: ${{ secrets.APIX_BOT_PASSPHRASE }}

update-changelog-header:
needs: [ release-config, validate-version-input, update-examples-reference-in-docs ]
needs: [ release-config, validate-inputs, update-examples-reference-in-docs ]
if: >-
!cancelled()
&& !contains(needs.*.result, 'failure')
Expand All @@ -77,7 +83,7 @@ jobs:

create-tag:
runs-on: ubuntu-latest
needs: [ release-config, validate-version-input, update-examples-reference-in-docs, update-changelog-header ]
needs: [ release-config, validate-inputs, update-examples-reference-in-docs, update-changelog-header ]
if: >-
!cancelled()
&& !contains(needs.*.result, 'failure')
Expand All @@ -99,7 +105,7 @@ jobs:
gpg_passphrase: ${{ secrets.PASSPHRASE }}

run-qa-acceptance-tests:
needs: [ release-config, validate-version-input, update-examples-reference-in-docs, update-changelog-header, create-tag ]
needs: [ release-config, validate-inputs, update-examples-reference-in-docs, update-changelog-header, create-tag ]
if: >-
!cancelled()
&& !contains(needs.*.result, 'failure')
Expand All @@ -112,7 +118,7 @@ jobs:

release:
runs-on: ubuntu-latest
needs: [ validate-version-input, update-examples-reference-in-docs, update-changelog-header, create-tag, run-qa-acceptance-tests ]
needs: [ validate-inputs, update-examples-reference-in-docs, update-changelog-header, create-tag, run-qa-acceptance-tests ]
# Release is skipped if there are failures in previous steps
if: >-
!cancelled()
Expand Down
23 changes: 23 additions & 0 deletions scripts/check-upgrade-guide-exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo pipefail

: "${1?"Tag of new release must be provided"}"

RELEASE_TAG=$1
RELEASE_NUMBER=$(echo "${RELEASE_TAG}" | tr -d v)

IFS='.' read -r MAJOR MINOR PATCH <<< "$RELEASE_NUMBER"

# Check if it's a major release (patch version is 0)
if [ "$PATCH" -eq 0 ]; then
UPGRADE_GUIDE_PATH="website/docs/guides/$MAJOR.$MINOR.$PATCH-upgrade-guide.html.markdown"
echo "Checking for the presence of $UPGRADE_GUIDE_PATH"
if [ ! -f "$UPGRADE_GUIDE_PATH" ]; then
echo "Stopping release procees, upgrade guide $UPGRADE_GUIDE_PATH does not exist."
exit 1
else
echo "Upgrade guide $UPGRADE_GUIDE_PATH exists."
fi
else
echo "No upgrade guide needed."
fi

0 comments on commit 22cfb52

Please sign in to comment.