83 lines
2.3 KiB
YAML
83 lines
2.3 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
pip install pytest
|
|
|
|
- name: Run tests
|
|
run: cd tests && python -m pytest -v
|
|
|
|
release:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Calculate next version
|
|
id: version
|
|
run: |
|
|
# Get latest tag, default to v0.0.0 if none
|
|
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n1)
|
|
if [ -z "$LATEST_TAG" ]; then
|
|
NEXT="v0.1.0"
|
|
else
|
|
# Bump patch version
|
|
MAJOR=$(echo $LATEST_TAG | cut -d. -f1 | tr -d 'v')
|
|
MINOR=$(echo $LATEST_TAG | cut -d. -f2)
|
|
PATCH=$(echo $LATEST_TAG | cut -d. -f3)
|
|
PATCH=$((PATCH + 1))
|
|
NEXT="v${MAJOR}.${MINOR}.${PATCH}"
|
|
fi
|
|
echo "TAG=$NEXT" >> $GITHUB_OUTPUT
|
|
echo "Next version: $NEXT"
|
|
|
|
- name: Generate changelog
|
|
id: changelog
|
|
run: |
|
|
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n1)
|
|
if [ -z "$PREV_TAG" ]; then
|
|
git log --pretty=format:"- %s (%h)" > CHANGELOG.md
|
|
else
|
|
git log --pretty=format:"- %s (%h)" ${PREV_TAG}..HEAD > CHANGELOG.md
|
|
fi
|
|
echo "--- Changelog ---"
|
|
cat CHANGELOG.md
|
|
|
|
- name: Create tag
|
|
run: |
|
|
git config user.name "github-actions"
|
|
git config user.email "github-actions@github.com"
|
|
git tag ${{ steps.version.outputs.TAG }}
|
|
git push origin ${{ steps.version.outputs.TAG }}
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ steps.version.outputs.TAG }}
|
|
name: "Release ${{ steps.version.outputs.TAG }}"
|
|
body_path: CHANGELOG.md
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|