Skip to content

Commit

Permalink
Add check to fail CI if VERSION file has not changed since last relea…
Browse files Browse the repository at this point in the history
…se (#9602)
  • Loading branch information
chainchad authored Jun 15, 2023
1 parent fee53a2 commit 4a4bb9d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/actions/version-file-bump/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: version-file-bump
description: "Ensure that the VERSION file has been bumped since the last release."
outputs:
result:
value: ${{ steps.compare.outputs.result }}
description: 'Result of the comparison'
runs:
using: composite
steps:
- name: Get latest release version
id: get-latest-version
shell: bash
run: |
untrimmed_ver=$(
curl --header "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
--request GET \
"https://api.github.com/repos/${{ github.repository }}/releases/latest?draft=false&prerelease=false" \
| jq -r .name
)
latest_version="${untrimmed_ver:1}"
echo "latest_version=${latest_version}" | tee -a "$GITHUB_OUTPUT"
- name: Get current version
id: get-current-version
shell: bash
run: |
current_version=$(head -n1 ./VERSION)
echo "current_version=${current_version}" | tee -a "$GITHUB_OUTPUT"
- name: Compare semantic versions
uses: smartcontractkit/chainlink-github-actions/[email protected]
id: compare
with:
version1: ${{ steps.get-current-version.outputs.current_version }}
operator: eq
version2: ${{ steps.get-latest-version.outputs.latest_version }}
- name: Fail if version not bumped
# XXX: The reason we are not checking if the current is greater than the
# latest release is to account for hot fixes which may have been branched
# from a previous tag.
shell: bash
env:
VERSION_NOT_BUMPED: ${{ steps.compare.outputs.result }}
run: |
if [[ "${VERSION_NOT_BUMPED:-}" = "true" ]]; then
echo "Version file not bumped since last release. Please bump the ./VERSION file in the root of the repo and commit the change."
exit 1
fi
11 changes: 11 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ on:
- 'release/**'

jobs:
checks:
name: 'Checks'
runs-on: ubuntu-20.04
steps:
- name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Check for VERSION file bump on tags
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: ./.github/actions/version-file-bump

build-sign-publish-chainlink:
needs: [checks]
if: ${{ ! startsWith(github.ref_name, 'release/') }}
runs-on: ubuntu-20.04
environment: build-publish
Expand Down

0 comments on commit 4a4bb9d

Please sign in to comment.