Release and Publish #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release and Publish | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: 'Version bump type' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.new }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Full history for release notes | |
| token: ${{ secrets.LEADR_OSS_PAT }} # PAT needed to bypass branch protection | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Bump version | |
| id: version | |
| run: | | |
| CURRENT="v$(uv version --short)" | |
| echo "current=${CURRENT}" >> $GITHUB_OUTPUT | |
| uv version --bump ${{ github.event.inputs.bump_type }} | |
| NEW="v$(uv version --short)" | |
| echo "new=${NEW}" >> $GITHUB_OUTPUT | |
| - name: Generate release notes | |
| run: | | |
| CURRENT="${{ steps.version.outputs.current }}" | |
| NEW="${{ steps.version.outputs.new }}" | |
| echo "# Release ${NEW}" > release_notes.md | |
| echo "" >> release_notes.md | |
| echo "## What's Changed" >> release_notes.md | |
| echo "" >> release_notes.md | |
| if git rev-parse "$CURRENT" >/dev/null 2>&1; then | |
| git log ${CURRENT}..HEAD --pretty=format:"- %s (%h)" --no-merges >> release_notes.md | |
| else | |
| git log --pretty=format:"- %s (%h)" --no-merges >> release_notes.md | |
| fi | |
| echo "" >> release_notes.md | |
| echo "" >> release_notes.md | |
| echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${CURRENT}...${NEW}" >> release_notes.md | |
| - name: Commit version bump | |
| run: | | |
| NEW_VERSION="${{ steps.version.outputs.new }}" | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add pyproject.toml uv.lock | |
| if ! git diff --staged --quiet; then | |
| git commit -m "chore: bump version to $NEW_VERSION [skip ci]" | |
| git push | |
| fi | |
| - name: Create Release | |
| id: create_release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.version.outputs.new }} | |
| name: ${{ steps.version.outputs.new }} | |
| body_path: release_notes.md | |
| draft: false | |
| prerelease: false | |
| - name: Set lowercase repo name | |
| id: repo | |
| run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./docker/api.Dockerfile | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: | | |
| ghcr.io/${{ steps.repo.outputs.name }}:latest | |
| ghcr.io/${{ steps.repo.outputs.name }}:${{ steps.version.outputs.new }} | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.new }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| publish-docs: | |
| needs: [release] | |
| uses: ./.github/workflows/docs.yaml | |
| with: | |
| version: ${{ needs.release.outputs.version }} | |
| secrets: inherit |