From 0b22cdd27eabf6e574b6a25c491cf6bf3733c5b9 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 24 Jan 2024 14:44:57 -0500 Subject: [PATCH] ci: update release actions from renee --- .github/workflows/draft-release.yml | 17 ++++++++++++++--- .github/workflows/post-release.yml | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 2f02bdb..899f0be 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -4,7 +4,10 @@ on: workflow_dispatch: inputs: version_tag: - description: Semantic version tag for next release. If not provided, it will be determined based on conventional commit history. + description: | + Semantic version tag for next release. + If not provided, it will be determined based on conventional commit history. + Example: v2.5.11 required: false type: string default: "" @@ -61,7 +64,10 @@ jobs: semver_pattern = 'v(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?' next_semver = re.match(semver_pattern, next_version) if not next_semver: - raise ValueError(f"Tag {next_version} does not match semantic versioning guidelines") + extra_msg = '' + if not next_version.startswith('v'): + extra_msg = "The tag does not start with 'v'." + raise ValueError(f"Tag {next_version} does not match semantic versioning guidelines. {extra_msg}\nView the guidelines here: https://semver.org/") # assert next version is only 1 greater than current current_semver = re.match(semver_pattern, current_version) @@ -109,7 +115,12 @@ jobs: citation._implementation.cffobj['version'] = "${{ env.NEXT_VERSION }}" citation._implementation.cffobj['date-released'] = "${{ env.DATE }}" with open('CITATION.cff', 'w') as outfile: - outfile.write(yaml.dump(citation._implementation.cffobj, sort_keys=False)) + outfile.write(yaml.dump(citation._implementation.cffobj, sort_keys=False, indent=2)) + + - uses: pre-commit/action@v3.0.0 + with: + extra_args: --files CITATION.cff CHANGELOG.md VERSION + continue-on-error: true - name: Commit & push to branch run: | diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml index 6acdc96..a642f1d 100644 --- a/.github/workflows/post-release.yml +++ b/.github/workflows/post-release.yml @@ -36,6 +36,11 @@ jobs: with open('VERSION', 'w') as outfile: outfile.write(f"{version}-dev\n") + - uses: pre-commit/action@v3.0.0 + with: + extra_args: --files CITATION.cff CHANGELOG.md VERSION + continue-on-error: true + - name: Open pull request run: | git add CHANGELOG.md VERSION