Skip to content

Commit

Permalink
ci: update release actions from renee
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Jan 24, 2024
1 parent 994971c commit 0b22cdd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down Expand Up @@ -61,7 +64,10 @@ jobs:
semver_pattern = 'v(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?: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<buildmetadata>[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)
Expand Down Expand Up @@ -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/[email protected]
with:
extra_args: --files CITATION.cff CHANGELOG.md VERSION
continue-on-error: true

- name: Commit & push to branch
run: |
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ jobs:
with open('VERSION', 'w') as outfile:
outfile.write(f"{version}-dev\n")
- uses: pre-commit/[email protected]
with:
extra_args: --files CITATION.cff CHANGELOG.md VERSION
continue-on-error: true

- name: Open pull request
run: |
git add CHANGELOG.md VERSION
Expand Down

0 comments on commit 0b22cdd

Please sign in to comment.