Skip to content

Commit

Permalink
feat(ci): check for major versions and use MAJOR_VERSION_ALLOWED= to …
Browse files Browse the repository at this point in the history
…release them (#6995)
  • Loading branch information
bshaffer authored Jan 24, 2024
1 parent aa41bc6 commit dd01622
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions .github/workflows/backwards-compatibility-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,43 @@ jobs:
--from=${{ steps.latest-release.outputs.release }} \
--to=origin/main --format=github-actions
# Ensure the release PR does not contain an unexpected (2.0.0) major version release
# Ensure the release PR does not contain an unexpected (e.g. 2.0.0) major version release
# Add "MAJOR_VERSION_ALLOWED=component1,component2" to the PR description to allow major version
# releases for those components
unexpected-major-version-check:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'release-please[bot]'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse allowed major versions
uses: actions-ecosystem/action-regex-match@v2
id: allowed-major-versions
with:
text: ${{ github.event.pull_request.body }}
regex: '^MAJOR_VERSION_ALLOWED=(.*)$'
flags: gm
- name: "Check for unexpected major version"
run: |
if [[ "true" == "${{ contains(github.event.pull_request.body, '2.0.0') }}" ]]; then
echo "Unexpected 2.0.0 major version release found"
# parse allowed major versions into an array
IFS=', ' read -r -a ALLOWED_MAJOR_VERSIONS <<< "${{ steps.allowed-major-versions.outputs.group1 }}"
# get all changed components
COMPONENTS=$(git diff origin/main --name-only | grep VERSION | xargs dirname)
FAIL=""
for COMPONENT in ${COMPONENTS}; do {
if [[ "$(cat $COMPONENT/VERSION)" == [123456789].0.0 ]]; then
# A new version is being released - make sure it's allowed
if [[ ${ALLOWED_MAJOR_VERSIONS[@]} =~ $COMPONENT ]]; then
echo "Major version release allowed: $COMPONENT"
else
echo "Unexpected major version release found: $COMPONENT"
FAIL="true"
fi
fi
}; done
if [[ "$FAIL" == "true" ]]; then
echo "Add \"MAJOR_VERSION_ALLOWED=component1,component2\" to the PR description to allow "
echo "major version releases for those components"
exit 1
fi

0 comments on commit dd01622

Please sign in to comment.