Skip to content

Commit

Permalink
Add build dist workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenwindflower committed Apr 7, 2024
1 parent 3208732 commit 0589376
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: macos-latest
strategy:
fail-fast: false
fail-fast: true
matrix:
python-version: ["3.11"]
steps:
Expand Down
80 changes: 80 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
),
Expand Down

0 comments on commit 0589376

Please sign in to comment.