From 233ea9a347a9008b9582e64c6a10e3686e1d064a Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Thu, 4 Nov 2021 08:59:49 -0400 Subject: [PATCH 01/12] Version bump should only happen on master --- .github/workflows/publish-to-pypi-test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 782e668..c570e3b 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -88,12 +88,14 @@ jobs: - name: Bump Version run: | bump2version minor setup.py + if: github.ref == 'refs/heads/master' - name: Push Commit from Bump2Version uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} + if: github.ref == 'refs/heads/master' - name: Build a binary wheel and a source tarball run: | @@ -109,7 +111,7 @@ jobs: uses: tj-actions/changed-files@v2.1 - name: Publish distribution 📦 to Test PyPI - if: contains(steps.changed-files.outputs.modified_files, 'setup.py') + if: github.ref == 'refs/heads/master' uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} From a5a995119c3ac7a20775f29d44e9a2e8d51fe6d2 Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Thu, 4 Nov 2021 09:09:15 -0400 Subject: [PATCH 02/12] Changed minor to patch version bumps --- .github/workflows/publish-to-pypi-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index c570e3b..4a65cc6 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -87,7 +87,7 @@ jobs: - name: Bump Version run: | - bump2version minor setup.py + bump2version patch setup.py if: github.ref == 'refs/heads/master' - name: Push Commit from Bump2Version From 06d3a4c3b78982c53c61f6e6ea56ba2cbb217124 Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Tue, 9 Nov 2021 12:02:42 -0500 Subject: [PATCH 03/12] Create release once version bumped on master --- .bumpversion.cfg | 2 +- .github/workflows/publish-to-pypi-test.yml | 24 ++++++++++++++++++---- setup.py | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 96df491..55df4d5 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.10.0 +current_version = 0.11.2 commit = True tag = True diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 4a65cc6..3c34e56 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -2,7 +2,7 @@ name: Publish Python 🐍 distribution 📦 to TestPyPI on: push: - branches-ignore: + branches: - master jobs: @@ -88,14 +88,12 @@ jobs: - name: Bump Version run: | bump2version patch setup.py - if: github.ref == 'refs/heads/master' - name: Push Commit from Bump2Version uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} - if: github.ref == 'refs/heads/master' - name: Build a binary wheel and a source tarball run: | @@ -111,8 +109,26 @@ jobs: uses: tj-actions/changed-files@v2.1 - name: Publish distribution 📦 to Test PyPI - if: github.ref == 'refs/heads/master' uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ + + release: + runs-on: ubuntu-latest + needs: [build-n-publish] + steps: + - uses: actions/checkout@master + - name: Create release + uses: Roang-zero1/github-create-release-action@master + with: + version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create GitHub release + uses: Roang-zero1/github-upload-release-artifacts-action@master + with: + args: + - ./dist/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/setup.py b/setup.py index 9ab8087..78a7053 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='hm_pyhelper', - version='0.10.0', + version='0.11.2', author="Nebra Ltd", author_email="support@nebra.com", description="Helium Python Helper", From 193fdbb8acca1d55017fd60414623e42754211c0 Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Tue, 9 Nov 2021 12:59:00 -0500 Subject: [PATCH 04/12] Restrict specific tasks to master only --- .github/workflows/publish-to-pypi-test.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 3c34e56..4d777e6 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -2,8 +2,7 @@ name: Publish Python 🐍 distribution 📦 to TestPyPI on: push: - branches: - - master + branches: '*' jobs: rust-compile: @@ -76,6 +75,7 @@ jobs: - name: Install bump2version run: | python -m pip install bump2version + if: github.ref == 'refs/heads/master' - name: Assign Git User Email run: | @@ -88,12 +88,14 @@ jobs: - name: Bump Version run: | bump2version patch setup.py + if: github.ref == 'refs/heads/master' - name: Push Commit from Bump2Version uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} + if: github.ref == 'refs/heads/master' - name: Build a binary wheel and a source tarball run: | @@ -113,10 +115,12 @@ jobs: with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ + if: github.ref == 'refs/heads/master' release: runs-on: ubuntu-latest needs: [build-n-publish] + if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@master - name: Create release From e84b38e16b4a400d7ea79d7d8aa6eb385e2db0ef Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Tue, 9 Nov 2021 13:03:55 -0500 Subject: [PATCH 05/12] Quick refactor on push event --- .github/workflows/publish-to-pypi-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 4d777e6..d9b6c99 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -1,8 +1,6 @@ name: Publish Python 🐍 distribution 📦 to TestPyPI -on: - push: - branches: '*' +on: [push] jobs: rust-compile: From c0030679c5ee92a57990bc3bc3f4a15e7e564b32 Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Tue, 9 Nov 2021 13:06:38 -0500 Subject: [PATCH 06/12] Fix for invalid workflow sequence --- .github/workflows/publish-to-pypi-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index d9b6c99..1f3674e 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -131,6 +131,6 @@ jobs: uses: Roang-zero1/github-upload-release-artifacts-action@master with: args: - - ./dist/* + - dist/ env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9c4c1a6eef22ee0a63ff6b5f5295c7ea8d97c151 Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Tue, 9 Nov 2021 13:10:51 -0500 Subject: [PATCH 07/12] Arguments sequence fix --- .github/workflows/publish-to-pypi-test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 1f3674e..76f3a9a 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -130,7 +130,8 @@ jobs: - name: Create GitHub release uses: Roang-zero1/github-upload-release-artifacts-action@master with: - args: - - dist/ + args: '[ + , ./dist/* + ]' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3aacd77e7d09e9da49dbb7b8740225eac0336dca Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Tue, 9 Nov 2021 19:24:51 -0500 Subject: [PATCH 08/12] Updated version on master --- .bumpversion.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 55df4d5..fe993eb 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.11.2 +current_version = 0.11.3 commit = True tag = True From 1cb5deef7f21d618b6fbe375eee8e186d07a0da7 Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Tue, 9 Nov 2021 19:44:18 -0500 Subject: [PATCH 09/12] Prevent possible loop --- .github/workflows/publish-to-pypi-test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 76f3a9a..c3259a0 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -6,6 +6,7 @@ jobs: rust-compile: name: Build gateway-mfr-rs runs-on: ubuntu-latest + if: "! contains(toJSON(github.event.commits.*.message), 'Bump version:')" steps: - name: Install stable toolchain uses: actions-rs/toolchain@v1 @@ -43,6 +44,7 @@ jobs: build-n-publish: name: Build and publish Python 🐍 distribution 📦 to TestPyPI runs-on: ubuntu-18.04 + if: "! contains(toJSON(github.event.commits.*.message), 'Bump version:')" needs: [rust-compile] steps: @@ -118,7 +120,8 @@ jobs: release: runs-on: ubuntu-latest needs: [build-n-publish] - if: github.ref == 'refs/heads/master' + if: | + ${{ (github.ref == 'refs/heads/master' && !contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} steps: - uses: actions/checkout@master - name: Create release From d73cbc70fcde796be4c3344d1e751972c0a1c6ed Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Tue, 9 Nov 2021 20:00:48 -0500 Subject: [PATCH 10/12] Patch up workflow --- .github/workflows/publish-to-pypi-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index c3259a0..4bd33ea 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -120,8 +120,7 @@ jobs: release: runs-on: ubuntu-latest needs: [build-n-publish] - if: | - ${{ (github.ref == 'refs/heads/master' && !contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} + if: ${{ (github.ref == 'refs/heads/master' && ! contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} steps: - uses: actions/checkout@master - name: Create release From 4726af5381c319451459dba2df4bdfe541730037 Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Thu, 11 Nov 2021 08:14:08 -0500 Subject: [PATCH 11/12] Working auto release after bump version --- .github/workflows/publish-to-pypi-test.yml | 47 +++++++++------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 4bd33ea..3c1c2b8 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -6,7 +6,6 @@ jobs: rust-compile: name: Build gateway-mfr-rs runs-on: ubuntu-latest - if: "! contains(toJSON(github.event.commits.*.message), 'Bump version:')" steps: - name: Install stable toolchain uses: actions-rs/toolchain@v1 @@ -44,11 +43,14 @@ jobs: build-n-publish: name: Build and publish Python 🐍 distribution 📦 to TestPyPI runs-on: ubuntu-18.04 - if: "! contains(toJSON(github.event.commits.*.message), 'Bump version:')" needs: [rust-compile] steps: - - uses: actions/checkout@master + - uses: actions/checkout@v2 + with: + github_token: ${{ secrets.PAT_TOKEN }} + persist-credentials: false + fetch-depth: 0 - name: Set up Python 3.7 uses: actions/setup-python@v1 @@ -88,14 +90,14 @@ jobs: - name: Bump Version run: | bump2version patch setup.py - if: github.ref == 'refs/heads/master' + if: ${{ (github.ref == 'refs/heads/master' && ! contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} - name: Push Commit from Bump2Version uses: ad-m/github-push-action@master with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ secrets.PAT_TOKEN }} branch: ${{ github.ref }} - if: github.ref == 'refs/heads/master' + if: ${{ (github.ref == 'refs/heads/master' && ! contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} - name: Build a binary wheel and a source tarball run: | @@ -115,25 +117,16 @@ jobs: with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ - if: github.ref == 'refs/heads/master' + if: ${{ (github.ref == 'refs/heads/master' && contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} - release: - runs-on: ubuntu-latest - needs: [build-n-publish] - if: ${{ (github.ref == 'refs/heads/master' && ! contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} - steps: - - uses: actions/checkout@master - - name: Create release - uses: Roang-zero1/github-create-release-action@master - with: - version_regex: ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create GitHub release - uses: Roang-zero1/github-upload-release-artifacts-action@master - with: - args: '[ - , ./dist/* - ]' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: 'Get Previous tag' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + + - uses: ncipollo/release-action@v1 + with: + artifacts: "dist/*" + # bodyFile: "body.md" + token: ${{ secrets.PAT_TOKEN }} + tag: ${{ steps.previoustag.outputs.tag }} + if: ${{ (github.ref == 'refs/heads/master' && contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} \ No newline at end of file From b0dff572dfae1256ca724ba5337150b5ee7d6ecc Mon Sep 17 00:00:00 2001 From: Sebastian Maj Date: Thu, 11 Nov 2021 10:49:33 -0500 Subject: [PATCH 12/12] Got this working with 1 workflow and GITHUB_TOKEN Successfully builds and releases binaries upon push to master Reference of this working: https://github.com/SebastianMaj/hm-pytester Version 0.9.29 and latest commit --- .github/workflows/publish-to-pypi-test.yml | 50 +++++++++++++++++++--- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-to-pypi-test.yml b/.github/workflows/publish-to-pypi-test.yml index 3c1c2b8..adec3d0 100644 --- a/.github/workflows/publish-to-pypi-test.yml +++ b/.github/workflows/publish-to-pypi-test.yml @@ -48,7 +48,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - github_token: ${{ secrets.PAT_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} persist-credentials: false fetch-depth: 0 @@ -95,7 +95,7 @@ jobs: - name: Push Commit from Bump2Version uses: ad-m/github-push-action@master with: - github_token: ${{ secrets.PAT_TOKEN }} + github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }} if: ${{ (github.ref == 'refs/heads/master' && ! contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} @@ -117,7 +117,46 @@ jobs: with: password: ${{ secrets.TEST_PYPI_API_TOKEN }} repository_url: https://test.pypi.org/legacy/ - if: ${{ (github.ref == 'refs/heads/master' && contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} + if: ${{ (github.ref == 'refs/heads/master' && ! contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} + + + release: + name: Release build on git + runs-on: ubuntu-18.04 + needs: [build-n-publish] + if: ${{ (github.ref == 'refs/heads/master') }} + + steps: + - uses: actions/checkout@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + + - name: Install pypa/build + run: | + python -m pip install build --user + + - name: Assign Git User Email + run: | + git config --global user.email "mrbump@nebra.com" + + - name: Assign Git User Name + run: | + git config --global user.name "Mr Bump Nebra" + + - name: Build a binary wheel and a source tarball + run: | + python -m build --sdist --wheel --outdir dist/ . + + - uses: actions/upload-artifact@v2 + with: + name: wheels + path: ./dist/* - name: 'Get Previous tag' id: previoustag @@ -127,6 +166,5 @@ jobs: with: artifacts: "dist/*" # bodyFile: "body.md" - token: ${{ secrets.PAT_TOKEN }} - tag: ${{ steps.previoustag.outputs.tag }} - if: ${{ (github.ref == 'refs/heads/master' && contains(toJSON(github.event.commits.*.message), 'Bump version:')) }} \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.previoustag.outputs.tag }} \ No newline at end of file