Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ name: Check and realese cosmpy
# secrets PYPI_USERNAME and PYPI_PASSWORD are required!
on:
pull_request:
branches: [main]
types: [closed]
branches:
- main
- develop
types: [closed]

jobs:
build:
Expand All @@ -23,6 +25,7 @@ jobs:
PYPI_PASSWORD: ${{secrets.FETCHBOT_PYPI_TOKEN}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required to make a release page
GH_TOKEN: ${{ github.token }}
IS_PRERELEASE: ${{ github.base_ref == 'develop' }}
run: |
pip install tomli packaging poetry
git config --global user.email "ci-bot@fetch.ai"
Expand Down
15 changes: 11 additions & 4 deletions scripts/do-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import tomli
from packaging.version import Version


ROOT = Path(__file__).parent.parent


Expand All @@ -46,6 +45,12 @@ def pypi_password(self) -> str:
"""Get PYPI password."""
return os.environ.get("PYPI_PASSWORD") or ""

@property
def is_prerelease(self) -> bool:
"""Whether this release should be marked as prerelease."""
raw = os.environ.get("IS_PRERELEASE", "").lower()
return raw in ("1", "true", "yes", "on")


class ReleaseTool:
"""Release helper tool."""
Expand Down Expand Up @@ -100,10 +105,11 @@ def push_tag(self, current_version) -> None:
"""Push tag to github."""
subprocess.check_call(f"git push origin v{current_version}", shell=True)

def make_release(self, current_version: Version, release_history: str) -> None:
def make_release(self, current_version: Version, release_history: str, prerelease: bool = False) -> None:
"""Make release on Github."""
prerelease_flag = "--prerelease" if prerelease else ""
subprocess.check_call(
f"""gh release create v{current_version} --title "v{current_version}" --notes "{release_history}" """,
f"""gh release create v{current_version} --title "v{current_version}" --notes "{release_history}" {prerelease_flag}""",
shell=True,
)

Expand Down Expand Up @@ -164,7 +170,8 @@ def main(self):
print("Tag pushed")

print("\nMake release")
self.make_release(current_version, release_history=histories[current_version])
self.make_release(current_version, release_history=histories[current_version],
prerelease=self._credentials.is_prerelease)
print("Release made." "")

print("\nDONE")
Expand Down
Loading