Skip to content

Python SDK v1.12.0

Python SDK v1.12.0 #11

Workflow file for this run

name: Publish to PyPI
on:
release:
types: [published]
permissions:
contents: read
jobs:
test:
name: Run Tests Before Publish
if: github.event.release.prerelease == false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]' pip-audit
- name: Verify release tag matches package version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
PACKAGE_VERSION="$(python -c 'from oilpriceapi.version import SDK_VERSION; print(SDK_VERSION)')"
if [ "$RELEASE_TAG" != "v$PACKAGE_VERSION" ]; then
echo "::error::Release tag $RELEASE_TAG does not match package version $PACKAGE_VERSION"
exit 1
fi
- name: Lint source with ruff
run: ruff check oilpriceapi/
- name: Run unit tests
run: pytest tests/ --ignore=tests/integration --ignore=tests/contract -m 'not slow' --cov=oilpriceapi -v
- name: Audit installed dependencies
run: pip-audit
publish:
name: Publish to PyPI
needs: test
if: github.event.release.prerelease == false
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # Required for trusted publishing
contents: write
steps:
- uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build 'jsonschema>=4.17,<4.24'
- name: Build package
run: python -m build
- name: Install and import the exact built wheel
run: ./scripts/clean-wheel-smoke.sh
- name: Build signed snippet manifest
run: |
python scripts/generate_snippet_manifest.py \
--source-commit "$GITHUB_SHA" \
--output artifacts/snippets/oilpriceapi-python-snippets-v1.json
- name: Attach snippet manifest to release
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "${{ github.event.release.tag_name }}" artifacts/snippets/* --clobber
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1