-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added action information and keys, minor touch ups
- Loading branch information
Showing
4 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python3 | ||
import json | ||
import subprocess | ||
|
||
|
||
def get_last_version() -> str: | ||
"""Return the version number of the last release.""" | ||
json_string = ( | ||
subprocess.run( | ||
["gh", "release", "view", "--json", "tagName"], | ||
check=True, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
.stdout.decode("utf8") | ||
.strip() | ||
) | ||
|
||
return json.loads(json_string)["tagName"] | ||
|
||
|
||
def bump_patch_number(version_number: str) -> str: | ||
"""Return a copy of `version_number` with the patch number incremented.""" | ||
major, minor, patch = version_number.split(".") | ||
if '-' in patch: | ||
patch = patch.split('-')[0] | ||
v = path.split('-')[1] | ||
return f"{major}.{minor}.{int(patch) + 1}-{v}" | ||
return f"{major}.{minor}.{int(patch) + 1}" | ||
|
||
|
||
def create_new_patch_release(): | ||
"""Create a new patch release on GitHub.""" | ||
try: | ||
last_version_number = get_last_version() | ||
except subprocess.CalledProcessError as err: | ||
'''if err.stderr.decode("utf8").startswith("HTTP 404:"): | ||
# The project doesn't have any releases yet. | ||
new_version_number = "0.0.1" | ||
else: | ||
raise''' | ||
new_version_number = "0.0.1" | ||
else: | ||
new_version_number = bump_patch_number(last_version_number) | ||
|
||
subprocess.run( | ||
["gh", "release", "create", "--generate-notes", new_version_number], | ||
check=True, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
create_new_patch_release() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Publish to PyPI.org | ||
#on: workflow_dispatch | ||
on: | ||
release: | ||
types: [published] | ||
jobs: | ||
pypi: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- run: python3 -m pip install --upgrade build && python3 -m build | ||
- name: Publish package | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Create a new patch release | ||
on: workflow_dispatch | ||
jobs: | ||
github: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Create new patch release | ||
run: .github/scripts/release.py | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters