From 1e86b3cd15652e2dddb232c9ecbffbd9bf6c295f Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Wed, 28 Oct 2020 19:38:53 +0000 Subject: [PATCH 1/3] [add] Added release automation (creates drafts automatically and pushes to pypi on release) --- .github/release-drafter-config.yml | 21 +++++++++++ .github/workflows/check-pypi.yml | 27 +++++++++++++++ .github/workflows/publish-pypi.yml | 50 +++++++++++++++++++++++++++ .github/workflows/release-drafter.yml | 19 ++++++++++ 4 files changed, 117 insertions(+) create mode 100644 .github/release-drafter-config.yml create mode 100644 .github/workflows/check-pypi.yml create mode 100644 .github/workflows/publish-pypi.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/release-drafter-config.yml b/.github/release-drafter-config.yml new file mode 100644 index 0000000..413d94f --- /dev/null +++ b/.github/release-drafter-config.yml @@ -0,0 +1,21 @@ +name-template: 'Version $NEXT_PATCH_VERSION' +tag-template: 'v$NEXT_PATCH_VERSION' +categories: + - title: '🚀Features' + labels: + - 'feature' + - 'enhancement' + - title: 'Bug Fixes' + labels: + - 'fix' + - 'bugfix' + - 'bug' + - title: 'Maintenance' + label: 'chore' +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +exclude-labels: + - 'skip-changelog' +template: | + ## Changes + + $CHANGES \ No newline at end of file diff --git a/.github/workflows/check-pypi.yml b/.github/workflows/check-pypi.yml new file mode 100644 index 0000000..5b21a30 --- /dev/null +++ b/.github/workflows/check-pypi.yml @@ -0,0 +1,27 @@ +name: Check if required secrets are set to publish to Pypi + +on: push + +jobs: + checksecret: + name: check if PYPI_TOKEN and TESTPYPI_TOKEN are set in github secrets + runs-on: ubuntu-latest + steps: + - name: Check PYPI_TOKEN + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + run: | + if ${{ env.PYPI_TOKEN == '' }} ; then + echo "PYPI_TOKEN secret is not set" + exit 1 + fi + - name: Check TESTPYPI_TOKEN + env: + TESTPYPI_TOKEN: ${{ secrets.TESTPYPI_TOKEN }} + run: | + if ${{ env.TESTPYPI_TOKEN == '' }} ; then + echo "TESTPYPI_TOKEN secret is not set" + exit 1 + fi + + diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..9ace164 --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,50 @@ +name: Publish Pypi +on: + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 2.7 + uses: actions/setup-python@v1 + with: + python-version: 2.7 + + - name: Install twine + run: | + pip install twine + + - name: Install wheel + run: | + pip install wheel + + - name: Create a source distribution + run: | + python setup.py sdist + + - name: Create a wheel + run: | + python setup.py bdist_wheel + + - name: Create a .pypirc + run: | + echo -e "[pypi]" >> ~/.pypirc + echo -e "username = __token__" >> ~/.pypirc + echo -e "password = ${{ secrets.PYPI_TOKEN }}" >> ~/.pypirc + echo -e "[testpypi]" >> ~/.pypirc + echo -e "username = __token__" >> ~/.pypirc + echo -e "password = ${{ secrets.TESTPYPI_TOKEN }}" >> ~/.pypirc + + - name: Publish to Test PyPI + if: github.event_name == 'release' + run: | + twine upload --skip-existing -r testpypi dist/* + + - name: Publish to PyPI + if: github.event_name == 'release' + run: | + twine upload -r pypi dist/* diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..c205014 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,19 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + config-name: release-drafter-config.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From a6ea1f4841a466361a396da5f75e305a508e7921 Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Mon, 15 Feb 2021 09:34:35 +0000 Subject: [PATCH 2/3] [fix] Fixes per PR review --- .github/workflows/publish-pypi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 9ace164..10a87d6 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: Set up Python 2.7 + - name: Set up Python 3.6 uses: actions/setup-python@v1 with: - python-version: 2.7 + python-version: 3.6 - name: Install twine run: | From aa16a86206d886655c0d5545239d243ddc82a2d0 Mon Sep 17 00:00:00 2001 From: filipecosta90 Date: Mon, 15 Feb 2021 09:38:44 +0000 Subject: [PATCH 3/3] [fix] Fixed lacking EOL on config files --- .github/release-drafter-config.yml | 2 +- .github/workflows/check-pypi.yml | 2 -- .github/workflows/release-drafter.yml | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/release-drafter-config.yml b/.github/release-drafter-config.yml index 413d94f..84791cc 100644 --- a/.github/release-drafter-config.yml +++ b/.github/release-drafter-config.yml @@ -18,4 +18,4 @@ exclude-labels: template: | ## Changes - $CHANGES \ No newline at end of file + $CHANGES diff --git a/.github/workflows/check-pypi.yml b/.github/workflows/check-pypi.yml index 5b21a30..e1d5b10 100644 --- a/.github/workflows/check-pypi.yml +++ b/.github/workflows/check-pypi.yml @@ -23,5 +23,3 @@ jobs: echo "TESTPYPI_TOKEN secret is not set" exit 1 fi - - diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index c205014..ec2d88b 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -16,4 +16,4 @@ jobs: # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml config-name: release-drafter-config.yml env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}