From 4f766bb163df7dbe113cf0c076132ebeb7615ea5 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Thu, 4 Jun 2020 17:46:25 +0100 Subject: [PATCH 1/6] feat: automate publishing to pypi --- .github/workflows/publish.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000000..6ebe5a23666 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +name: Publish to PyPi + +# only build & publish to PyPi once release notes are published +# this ensures we have release notes correctly, tags, changelog, etc. +# TODO: Check source code version against tags and changelog for match + +on: + release: + types: [published] + +jobs: + upload: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: "3.8" + - name: Install dependencies + run: make dev + - name: Run all tests, linting and baselines + run: make pr + - name: Build python package and wheel + run: poetry build + - name: Upload to PyPi test + run: make release-test + env: + PYPI_USERNAME: __token__ + PYPI_TOKEN: ${{ secrets.PYPI_TEST_TOKEN }} + - name: Upload to PyPi prod + run: make release-prod + env: + TWINE_USERNAME: __token__ + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} From 03608c3f17c09f95e7825183a6cd186ed828227a Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Fri, 5 Jun 2020 16:26:09 +0100 Subject: [PATCH 2/6] feat: ensure version is in package and changelog --- .github/workflows/publish.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6ebe5a23666..a35713ba2df 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,6 @@ name: Publish to PyPi # only build & publish to PyPi once release notes are published # this ensures we have release notes correctly, tags, changelog, etc. -# TODO: Check source code version against tags and changelog for match on: release: @@ -17,6 +16,14 @@ jobs: uses: actions/setup-python@v1 with: python-version: "3.8" + - name: Set release notes tag + run: | + export RELEASE_TAG_VERSION=${{ github.event.release.tag_name }} + echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} + - name: Ensure new version is also set in pyproject and CHANGELOG + run: | + grep ${RELEASE_TAG_VERSION} CHANGELOG.md + grep ${RELEASE_TAG_VERSION} pyproject.toml - name: Install dependencies run: make dev - name: Run all tests, linting and baselines From ec0933a8fe19d961d8cef18d644d02d33668d4fd Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Fri, 5 Jun 2020 16:31:10 +0100 Subject: [PATCH 3/6] feat: sync up master after release Signed-off-by: heitorlessa --- .github/workflows/publish.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a35713ba2df..c0567e28d98 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -40,3 +40,15 @@ jobs: env: TWINE_USERNAME: __token__ PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + + sync_master: + needs: upload + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Sync master from detached head + # If version matches CHANGELOG and pyproject.toml + # If it passes all checks, successfully releases to test and prod + # Then sync up master with latest source code release + # where commit message will be Release notes title + run: git push origin HEAD:refs/heads/master --force From 5456a7a6635cc5722e21830ed4128dc56be9e662 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Fri, 5 Jun 2020 16:45:35 +0100 Subject: [PATCH 4/6] chore: document release process in action Signed-off-by: heitorlessa --- .github/workflows/publish.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c0567e28d98..0cc75074fe3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,7 +1,23 @@ name: Publish to PyPi -# only build & publish to PyPi once release notes are published -# this ensures we have release notes correctly, tags, changelog, etc. +# RELEASE PROCESS +# +# === Manual activities === +# +# 1. Document human readable changes in CHANGELOG +# 2. Bump package version using poetry version +# 3. Create a PR to develop branch, and merge if all tests pass +# 4. Edit the current draft release notes +# 5. If not already set, use `v` as a tag, and select develop as target branch +# +# === Automated activities === +# +# 1. Extract release notes tag that was published +# 2. Ensure release notes tag match what's in CHANGELOG and pyproject +# 3. Run tests, linting, security and complexity base line +# 4. Publish package to PyPi test repository +# 5. Publish package to PyPi prod repository +# 6. Push latest release source code to master using release title as the commit message on: release: From 53a0fe6ad753688f3253c6831c8a136699095a41 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sat, 6 Jun 2020 17:48:19 +0100 Subject: [PATCH 5/6] improv: use exact match for release tag version Signed-off-by: heitorlessa --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0cc75074fe3..984021682b1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -38,8 +38,8 @@ jobs: echo ::set-env name=RELEASE_TAG_VERSION::${RELEASE_TAG_VERSION:1} - name: Ensure new version is also set in pyproject and CHANGELOG run: | - grep ${RELEASE_TAG_VERSION} CHANGELOG.md - grep ${RELEASE_TAG_VERSION} pyproject.toml + grep --regexp "\[${RELEASE_TAG_VERSION}\]" CHANGELOG.md + grep --regexp "version \= \"${RELEASE_TAG_VERSION}\"" pyproject.toml - name: Install dependencies run: make dev - name: Run all tests, linting and baselines From b2e9b1c54eb88a794ac8ab4e11e10eabab71d186 Mon Sep 17 00:00:00 2001 From: heitorlessa Date: Sat, 6 Jun 2020 18:00:32 +0100 Subject: [PATCH 6/6] fix: PYPI_USERNAME typo Signed-off-by: heitorlessa --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 984021682b1..be1dc46af69 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -54,7 +54,7 @@ jobs: - name: Upload to PyPi prod run: make release-prod env: - TWINE_USERNAME: __token__ + PYPI_USERNAME: __token__ PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} sync_master: