Skip to content

Fix ArXiv search (#16) #11

Fix ArXiv search (#16)

Fix ArXiv search (#16) #11

Workflow file for this run

name: Auto Release on Version Change
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'pyproject.toml'
jobs:
check-version-and-release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # For PyPI trusted publishing
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install UV
uses: astral-sh/setup-uv@v3
- name: Check if version changed
id: version_check
run: |
CURRENT_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
git checkout HEAD~1 -- pyproject.toml
PREVIOUS_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])" 2>/dev/null || echo "0.0.0")
git checkout HEAD -- pyproject.toml
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
else
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "Version did not change"
fi
- name: Generate changelog
if: steps.version_check.outputs.version_changed == 'true'
id: changelog
run: |
VERSION=${{ steps.version_check.outputs.current_version }}
# Get commits since last tag (or all if no tags)
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" --no-merges)
else
CHANGELOG=$(git log ${LAST_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi
# Create release body
{
echo 'release_body<<EOF'
echo "## What's Changed"
echo ""
echo "$CHANGELOG"
echo ""
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${LAST_TAG}...v${VERSION}"
echo EOF
} >> $GITHUB_OUTPUT
- name: Create git tag
if: steps.version_check.outputs.version_changed == 'true'
run: |
VERSION=${{ steps.version_check.outputs.current_version }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${VERSION}" -m "Release ${VERSION}"
git push origin "${VERSION}"
- name: Build package with UV
if: steps.version_check.outputs.version_changed == 'true'
run: |
uv build
- name: Publish to PyPI
if: steps.version_check.outputs.version_changed == 'true'
run: |
uv publish
- name: Create GitHub Release
if: steps.version_check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version_check.outputs.current_version }}
name: Release ${{ steps.version_check.outputs.current_version }}
body: ${{ steps.changelog.outputs.release_body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}