From 50f1d2f04ab0314ae142f50f903c7f8dd7602042 Mon Sep 17 00:00:00 2001 From: Jye Cusch Date: Fri, 25 Jun 2021 15:23:46 +1000 Subject: [PATCH] ci: add release and publish workflows --- .github/workflows/draft_release.yaml | 30 ++++++++++++++++++++++++++++ .github/workflows/publish.yaml | 26 ++++++++++++++++++++++++ .github/workflows/test.yaml | 2 +- setup.py | 2 +- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/draft_release.yaml create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/draft_release.yaml b/.github/workflows/draft_release.yaml new file mode 100644 index 0000000..dab735b --- /dev/null +++ b/.github/workflows/draft_release.yaml @@ -0,0 +1,30 @@ +on: + pull_request: + types: [closed] + branches: + - 'main' + +jobs: + version: + if: github.event.pull_request.merged == true + name: Version and Draft Release + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v5.5 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Create a GitHub Draft Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag_version.outputs.new_tag }} + release_name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }} + draft: true + prerelease: false \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..f53958d --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,26 @@ +name: Publish release to Pypi + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.1 + with: + token: ${{secrets.SUBMOD_PAT}} + submodules: recursive + fetch-depth: 0 # needed to retrieve most recent tag + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: Build + run: make build + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 10a6518..6da3f81 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,7 +15,7 @@ jobs: with: token: ${{secrets.SUBMOD_PAT}} submodules: recursive - #lfs: true + fetch-depth: 0 # needed to retrieve most recent tag - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: diff --git a/setup.py b/setup.py index cf93c2a..4ba4e62 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ def get_current_version_tag(): base_tag, num_commits = dev_tags.pop().split("-")[:2] return "{}.dev{}".format(base_tag, num_commits)[1:] else: - raise Exception("Unable to determine or construct version from git tags.") + return "0.0.0.dev0" with open("README.md", "r") as readme_file: