Skip to content

Commit

Permalink
Added action information and keys, minor touch ups
Browse files Browse the repository at this point in the history
  • Loading branch information
kcelebi committed Apr 11, 2023
1 parent 282e4fa commit f49919f
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 6 deletions.
53 changes: 53 additions & 0 deletions .github/scripts/release.py
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()
18 changes: 18 additions & 0 deletions .github/workflows/publish.yml
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 }}
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
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 }}
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![kcelebi](https://circleci.com/gh/kcelebi/riscv-assembler.svg?style=svg)](https://circleci.com/gh/kcelebi/riscv-assembler)
[![kcelebi](https://circleci.com/gh/celebi-pkg/riscv-assembler.svg?style=svg)](https://circleci.com/gh/celebi-pkg/riscv-assembler)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

![example](references/mdimg.png)
Expand All @@ -16,8 +16,4 @@ The package can be installed using pip:

If issues arise try:

$ python3 -m pip install riscv-assembler

It's possible tha the ``bitstring`` dependency might not install correctly. If this occurs, you can simply pip install it separately:

$ pip install bitstring
$ python3 -m pip install riscv-assembler

0 comments on commit f49919f

Please sign in to comment.