Skip to content

fix: inline bundled cli box definitions #4

fix: inline bundled cli box definitions

fix: inline bundled cli box definitions #4

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install package and test dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev]
- name: Run tests
run: pytest -q
build:
name: Build distributions
runs-on: ubuntu-latest
needs: test
outputs:
package_version: ${{ steps.version.outputs.package_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install build tooling
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Read package version
id: version
run: |
python - <<'PY' >> "$GITHUB_OUTPUT"
from pathlib import Path
import re
text = Path("src/pyinkcli/__init__.py").read_text(encoding="utf-8")
match = re.search(r'^__version__ = "([^"]+)"$', text, re.MULTILINE)
if not match:
raise SystemExit("Unable to find __version__ in src/pyinkcli/__init__.py")
print(f"package_version={match.group(1)}")
PY
- name: Validate tag matches package version
if: startsWith(github.ref, 'refs/tags/')
env:
PACKAGE_VERSION: ${{ steps.version.outputs.package_version }}
GIT_TAG: ${{ github.ref_name }}
run: |
if [ "$GIT_TAG" != "v$PACKAGE_VERSION" ]; then
echo "Tag $GIT_TAG does not match package version v$PACKAGE_VERSION"
exit 1
fi
- name: Build package
run: python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: pyinkcli-${{ steps.version.outputs.package_version }}-dist
path: dist/*
publish_pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: build
environment:
name: pypi
url: https://pypi.org/p/pyinkcli
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: pyinkcli-${{ needs.build.outputs.package_version }}-dist
path: dist
- name: Publish distribution
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: dist
github_release:
name: GitHub Release
runs-on: ubuntu-latest
needs:
- build
- publish_pypi
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: pyinkcli-${{ needs.build.outputs.package_version }}-dist
path: release-assets
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: release-assets/*
generate_release_notes: true