Skip to content

Commit

Permalink
Updated sequential build-and-release workflows on GitHub.
Browse files Browse the repository at this point in the history
  • Loading branch information
adivekar-utexas committed Jan 18, 2025
1 parent 8588bd7 commit 45b69b4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: release

on:
push:
tags:
- "v*" # Trigger only when a tag like v1.2.3 is pushed

jobs:
pypi:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_branch == 'main' }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Required for Git versioning

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install Hatch & Twine
run: |
python -m pip install --upgrade pip
python -m pip install uv
python -m uv pip install hatch twine
- name: Verify Version from Git Tag
run: hatch version

- name: Build Package
run: hatch build

- name: Publish to PyPI
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
22 changes: 4 additions & 18 deletions .github/workflows/build.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Test
name: tests

on:
push:
Expand All @@ -7,7 +7,7 @@ on:
branches: [ "main" ]

jobs:
test-and-build:
pytest:
runs-on: ubuntu-latest

steps:
Expand All @@ -19,28 +19,14 @@ jobs:
with:
python-version: "3.11"

- name: Install build requirements
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Install test requirements
# Adjust to install test dependencies, or do it all in one step
# Install package dependencies:
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade uv
python -m uv pip install --upgrade pytest
python -m uv pip install -e .
- name: Run tests
run: |
pytest tests/
- name: Build wheel and sdist
run: |
python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-artifacts
path: dist/*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*#
*.pyc
*.DS_Store

dist/*
__pycache__/
*.py[cod]
*$py.class
Expand Down

0 comments on commit 45b69b4

Please sign in to comment.