name: Release
on:
push:
tags:
- "v*"
env:
PYTHON_VERSION: "3.11"
jobs:
build:
name: Build Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
name: dist
path: dist/
test:
name: Test Release Build
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Download artifacts
uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- name: Install from wheel
run: |
pip install dist/*.whl
- name: Test import
run: |
python -c "import contextfs; print(f'contextfs version: {contextfs.__version__}')"
publish-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build, test]
environment: release
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build, test]
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v7
with:
name: dist
path: dist/
- name: Get version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Generate changelog
id: changelog
run: |
CHANGELOG=$(python scripts/generate_changelog.py --format markdown 2>/dev/null || echo "- See commit history for changes")
echo "changelog<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: false
draft: false
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
make_latest: true
body: |
## ContextFS v${{ steps.version.outputs.version }}
### Installation
```bash
pip install contextfs==${{ steps.version.outputs.version }}
```
Or with uvx:
```bash
uvx contextfs --version
```
### What's Changed
${{ steps.changelog.outputs.changelog }}
### Links
- [Documentation](https://magnetonio.github.io/contextfs/)
- [PyPI](https://pypi.org/project/contextfs/${{ steps.version.outputs.version }}/)
- [Changelog](https://github.com/MagnetonIO/contextfs/commits/v${{ steps.version.outputs.version }})