Repository navigation
Merge pull request #99 from OO-LD/ci-semver-changelog #2
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-main | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| concurrency: | |
| group: release | |
| cancel-in-progress: false | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write # OIDC trusted publishing to PyPI | |
| contents: write # push the release commit and tag, create the GitHub release | |
| outputs: | |
| released: ${{ steps.version.outputs.released }} | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # full history + tags so PSR can analyze commits | |
| ref: main | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Configure git identity | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Semantic release version | |
| id: version | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| before=$(git rev-parse HEAD) | |
| uv run semantic-release version | |
| after=$(git rev-parse HEAD) | |
| if [ "$before" != "$after" ]; then | |
| tag=$(git tag --points-at HEAD | grep -E '^v[0-9]' | head -1) | |
| echo "released=true" >> "$GITHUB_OUTPUT" | |
| echo "version=${tag#v}" >> "$GITHUB_OUTPUT" | |
| echo "Released $tag" | |
| else | |
| echo "released=false" >> "$GITHUB_OUTPUT" | |
| echo "No release for this push." | |
| fi | |
| - name: Build package | |
| if: steps.version.outputs.released == 'true' | |
| run: uv build | |
| - name: Check package metadata | |
| if: steps.version.outputs.released == 'true' | |
| run: uvx twine check dist/* | |
| - name: Publish to PyPI (OIDC trusted publishing) | |
| if: steps.version.outputs.released == 'true' | |
| run: uv publish --trusted-publishing always | |
| deploy-docs: | |
| needs: release | |
| if: needs.release.outputs.released == 'true' | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main # include the release commit just pushed by PSR | |
| - name: Set up the environment | |
| uses: ./.github/actions/setup-python-env | |
| - name: Build documentation | |
| run: uv run zensical build --clean | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: site | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |