From 4a2ce76af757b64a4513f9d36062f1ad9ca969f2 Mon Sep 17 00:00:00 2001 From: Sam Andrello Date: Wed, 7 Aug 2024 17:27:47 -0400 Subject: [PATCH 1/4] Fix pre-commit stage, add release workflow --- .github/workflows/release.yml | 45 +++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..62d9f27d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,45 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + build-and-release: + strategy: + matrix: + os: ["macos-latest", "ubuntu-latest", "windows-latest"] + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + + - name: Build package + run: | + python setup.py sdist bdist_wheel + + - name: Upload package to PyPI + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python -m twine upload dist/* + + - name: Upload artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: dist-${{ matrix.os }} + path: dist/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8aedd156..5dcd8d64 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,4 +42,4 @@ repos: - id: no-commit-to-branch name: Prevent Commit to Main Branch args: ["--branch", "main"] - stages: [pre-commit] + stages: [commit] From b1a4156bd52e227e6ba57aea35866e4b7a291125 Mon Sep 17 00:00:00 2001 From: Sam Andrello Date: Thu, 8 Aug 2024 11:42:54 -0400 Subject: [PATCH 2/4] use build --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62d9f27d..53016de5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,11 +24,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + python -m pip install --upgrade build pip install setuptools wheel twine - name: Build package run: | - python setup.py sdist bdist_wheel + python -m build - name: Upload package to PyPI env: From 7213284ff02f22de3c6cb9810019ed06f14214fb Mon Sep 17 00:00:00 2001 From: Sam Andrello Date: Thu, 8 Aug 2024 14:19:06 -0400 Subject: [PATCH 3/4] use manual activation for wkfl; add pypi upload --- .github/workflows/release.yml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 53016de5..e85e0231 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,7 @@ -name: Release +name: Release-to-PyPI on: - push: - tags: - - 'v*.*.*' + workflow_dispatch: jobs: build-and-release: @@ -31,16 +29,23 @@ jobs: run: | python -m build - - name: Upload package to PyPI - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python -m twine upload dist/* - - name: Upload artifacts - if: always() uses: actions/upload-artifact@v3 with: name: dist-${{ matrix.os }} path: dist/* + + publish: + needs: build-and-release + runs-on: ubuntu-latest + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: dist-${{ matrix.os }} + path: dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} From 0c5853c1a2e9b745dd114c098ee30bfa9c92ab37 Mon Sep 17 00:00:00 2001 From: Sam Andrello Date: Thu, 8 Aug 2024 14:38:30 -0400 Subject: [PATCH 4/4] changed hook stage to pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5dcd8d64..8aedd156 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,4 +42,4 @@ repos: - id: no-commit-to-branch name: Prevent Commit to Main Branch args: ["--branch", "main"] - stages: [commit] + stages: [pre-commit]