From 05893764aa0b148756d5e5f79412f22813b128e2 Mon Sep 17 00:00:00 2001 From: gwen windflower Date: Sun, 7 Apr 2024 14:15:34 -0500 Subject: [PATCH] Add build dist workflow --- .github/workflows/ci.yml | 2 +- .github/workflows/publish.yml | 80 +++++++++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a125e71..c1ff7ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: build: runs-on: macos-latest strategy: - fail-fast: false + fail-fast: true matrix: python-version: ["3.11"] steps: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..6fe2d76 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,80 @@ +name: Publish to PyPI + +on: + push: + branches: + - main + +jobs: + build: + name: Build dist + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install pypa/build + run: | + python3 -m pip install build --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish: + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: macos-latest + environment: + name: pypi + url: https://pypi.org/p/jaffle-shop-generator + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish dist to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: Publish GitHub Release + needs: + - publish-to-pypi + runs-on: macos-latest + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v1.2.3 + with: + inputs: | + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}' diff --git a/setup.py b/setup.py index 00f47a2..14f00a3 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def parse_requirements(filename): requirements = parse_requirements("requirements.in") setup( name="jaffle-shop-generator", - version="0.2", + version="0.4.0", packages=find_packages( exclude=["*.tests", "*.tests.*", "tests.*", "tests"], ),