Skip to content

Commit

Permalink
feat(ci): publish to pypi from ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dairiki committed Sep 5, 2024
1 parent cce8f99 commit 6be1fe7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Tests

on:
push:
branches: ["*"]
tags: ["v*"]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
tests:
name: Run Tests
uses: ./.github/workflows/tests.yml

pypi-publish:
name: Upload to PyPI
needs: tests
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
environment:
name: pypi
url: https://pypi.org/p/barnhunt
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
24 changes: 20 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Tests

on:
push:
branches: ["*"]
pull_request:
branches: [main]
workflow_call:
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
workflow_dispatch:

jobs:
tests:
Expand Down Expand Up @@ -93,3 +92,20 @@ jobs:
- run: pre-commit run -a
- run: tox r -e lint
if: ${{ success() || failure() }}

build:
name: Build python package
needs: [coverage, lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: python -m pip install --upgrade pip
- run: python -m pip install build
- run: python -m build .
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 1 # save money

0 comments on commit 6be1fe7

Please sign in to comment.