- CI workflow: ruff lint/format, pytest across Python 3.10/3.12/3.13 - Auto-release workflow: conventional commits drive semver bumps - 11 unit tests covering env parsing, multipart encoding, metadata embedding, upload flow - pyproject.toml with ruff/mypy/pytest config Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
82 lines
2.6 KiB
YAML
82 lines
2.6 KiB
YAML
name: Auto Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
if: >-
|
|
!startsWith(github.event.head_commit.message, 'chore:') &&
|
|
!startsWith(github.event.head_commit.message, 'ci:') &&
|
|
!startsWith(github.event.head_commit.message, 'docs:') &&
|
|
!startsWith(github.event.head_commit.message, 'test:') &&
|
|
!startsWith(github.event.head_commit.message, 'chore(release):')
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.13"
|
|
|
|
- name: Determine bump type
|
|
id: bump
|
|
run: |
|
|
MSG="${{ github.event.head_commit.message }}"
|
|
if echo "$MSG" | grep -qE '^feat!:|BREAKING CHANGE'; then
|
|
echo "type=major" >> "$GITHUB_OUTPUT"
|
|
elif echo "$MSG" | grep -qE '^feat(\(.*\))?:'; then
|
|
echo "type=minor" >> "$GITHUB_OUTPUT"
|
|
elif echo "$MSG" | grep -qE '^fix(\(.*\))?:'; then
|
|
echo "type=patch" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "type=patch" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Bump version
|
|
id: version
|
|
run: |
|
|
CURRENT=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
|
|
IFS='.' read -r major minor patch <<< "$CURRENT"
|
|
|
|
BUMP="${{ steps.bump.outputs.type }}"
|
|
if [ "$BUMP" = "major" ]; then
|
|
major=$((major + 1)); minor=0; patch=0
|
|
elif [ "$BUMP" = "minor" ]; then
|
|
minor=$((minor + 1)); patch=0
|
|
else
|
|
patch=$((patch + 1))
|
|
fi
|
|
|
|
NEW="$major.$minor.$patch"
|
|
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
|
|
echo "new=$NEW" >> "$GITHUB_OUTPUT"
|
|
echo "Bumping $CURRENT → $NEW ($BUMP)"
|
|
|
|
- name: Update pyproject.toml
|
|
run: |
|
|
sed -i "s/version = \"${{ steps.version.outputs.current }}\"/version = \"${{ steps.version.outputs.new }}\"/" pyproject.toml
|
|
|
|
- name: Commit and tag
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git add pyproject.toml
|
|
git commit -m "chore(release): v${{ steps.version.outputs.new }}"
|
|
git tag "v${{ steps.version.outputs.new }}"
|
|
git push origin main --tags
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: "v${{ steps.version.outputs.new }}"
|
|
name: "v${{ steps.version.outputs.new }}"
|
|
generate_release_notes: true
|