Add CI job to check that release version matches repo file contents

This commit is contained in:
Hood Chatham 2024-02-28 14:03:57 -08:00
parent e6e4750bff
commit 6a1b0b09b6
2 changed files with 43 additions and 4 deletions

View File

@ -479,6 +479,18 @@ jobs:
- store_artifacts:
path: /root/repo/dist/benchmarks.json
check-release-version:
# Check that the tag matches the version numbers in the repo and fail the
# release if not
<<: *defaults
steps:
- checkout
- run:
name: check-release-version
command: |
./tools/bump_version --check --new-version ${CIRCLE_TAG}
deploy-release:
# To reduce chance of deployment issues, try to keep the steps here as
# similar as possible to the steps in deploy-dev!
@ -515,8 +527,14 @@ jobs:
# If it has an 'a' in the tag it's an alpha so mark it as a prelease
[[ "${CIRCLE_TAG}" =~ a ]] && export MAYBE_PRE_RELEASE=-prerelease
/tmp/ghr-bin -t "${GITHUB_TOKEN}" -u "${CIRCLE_PROJECT_USERNAME}" \
-r "${CIRCLE_PROJECT_REPONAME}" -c "${CIRCLE_SHA1}" \
# Options have to come first, last two lines have to be
# ${CIRCLE_TAG} and dist.
# TODO: Should we get rid of -delete?
/tmp/ghr-bin \
-t "${GITHUB_TOKEN}" \
-u "${CIRCLE_PROJECT_USERNAME}" \
-r "${CIRCLE_PROJECT_REPONAME}" \
-c "${CIRCLE_SHA1}" \
-delete \
${MAYBE_PRE_RELEASE} \
"${CIRCLE_TAG}" \
@ -931,8 +949,16 @@ workflows:
tags:
only: /.*/
- check-release-version:
filters:
branches:
ignore: /.*/
tags:
only: /^\d+\.\d+\.\w+$/
- deploy-release:
requires:
- check-release-version
- test-core-firefox
- test-packages-firefox
- build-pyodide-debug

View File

@ -178,6 +178,11 @@ def parse_args():
parser.add_argument(
"--dry-run", action="store_true", help="Don't actually write anything"
)
parser.add_argument(
"--check",
action="store_true",
help="Compare the current contents to the updated contents and fail if it would change anything",
)
return parser.parse_args()
@ -210,12 +215,20 @@ def main():
if new_content is not None:
update_queue.append((target, new_content))
if args.check:
if update_queue:
print("Version update would change files, failing", file=sys.stderr)
return 1
return 0
if args.dry_run:
return
return 0
for target, content in update_queue:
target.file.write_text(content)
return 0
if __name__ == "__main__":
main()
import sys
sys.exit(main())