Skip to content

Commit

Permalink
Simplify workflow, Automate GitHub releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Zaczero committed May 7, 2024
1 parent 0061616 commit c43af9d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 67 deletions.
57 changes: 0 additions & 57 deletions .github/workflows/test.yaml

This file was deleted.

81 changes: 71 additions & 10 deletions .github/workflows/deploy.yaml → .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@ name: Deployment

on:
push:
tags:
- "*"
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
deploy:
name: Publish to PyPI
test:
name: Run tests
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/starlette-compress
permissions:
id-token: write
contents: read

steps:
- name: Checkout repository
Expand Down Expand Up @@ -65,5 +60,71 @@ jobs:
run: |
nix-shell --pure --run "poetry build"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish-pypi:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
name: Publish to PyPI
needs: test
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/starlette-compress
permissions:
id-token: write
contents: read

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-gh:
name: Publish to GitHub Release
needs: publish-pypi
runs-on: ubuntu-latest

permissions:
id-token: write
contents: write

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Sign with Sigstore
uses: sigstore/[email protected]
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 signed artifacts
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'

0 comments on commit c43af9d

Please sign in to comment.