|
| 1 | +name: Release and Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + id-token: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release-and-publish: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Set up Python |
| 20 | + uses: actions/setup-python@v4 |
| 21 | + with: |
| 22 | + python-version: '3.x' |
| 23 | + |
| 24 | + # Get current version |
| 25 | + - name: Get current version |
| 26 | + id: ver |
| 27 | + run: | |
| 28 | + cur=$(cat src/veedb/VERSION 2>/dev/null || echo "0.0.0") |
| 29 | + echo "current=$cur" >> "$GITHUB_OUTPUT" |
| 30 | +
|
| 31 | + # Bump patch version |
| 32 | + - name: Bump patch version |
| 33 | + id: bump |
| 34 | + run: | |
| 35 | + IFS='.' read -r MAJ MIN PAT <<< "${{ steps.ver.outputs.current }}" |
| 36 | + PAT=$((PAT + 1)) |
| 37 | + NEW="$MAJ.$MIN.$PAT" |
| 38 | + echo "$NEW" > src/veedb/VERSION |
| 39 | + echo "new=$NEW" >> "$GITHUB_OUTPUT" |
| 40 | +
|
| 41 | + # Commit and tag |
| 42 | + - name: Commit and tag |
| 43 | + env: |
| 44 | + NEW_VERSION: ${{ steps.bump.outputs.new }} |
| 45 | + run: | |
| 46 | + git config user.name "github-actions" |
| 47 | + git config user.email "[email protected]" |
| 48 | + git add src/veedb/VERSION |
| 49 | + git commit -m "chore: bump version to v$NEW_VERSION [skip ci]" || true |
| 50 | + git tag -a "v$NEW_VERSION" -m "Release v$NEW_VERSION" |
| 51 | + git push origin HEAD |
| 52 | + git push origin "v$NEW_VERSION" |
| 53 | +
|
| 54 | + # Build package |
| 55 | + - name: Install build tools |
| 56 | + run: | |
| 57 | + python -m pip install --upgrade pip |
| 58 | + pip install build twine |
| 59 | +
|
| 60 | + - name: Build package |
| 61 | + run: python -m build |
| 62 | + |
| 63 | + # Create GitHub Release |
| 64 | + - name: Create GitHub Release |
| 65 | + uses: softprops/action-gh-release@v1 |
| 66 | + with: |
| 67 | + tag_name: v${{ steps.bump.outputs.new }} |
| 68 | + name: Release v${{ steps.bump.outputs.new }} |
| 69 | + draft: false |
| 70 | + prerelease: false |
| 71 | + generate_release_notes: true |
| 72 | + env: |
| 73 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + # Publish to PyPI |
| 76 | + - name: Publish to PyPI |
| 77 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 78 | + with: |
| 79 | + user: __token__ |
| 80 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments