[feat] tag releases automatically #18
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: publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| diff: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check for changes | |
| id: changes-check | |
| run: | | |
| if git diff --quiet HEAD~1 HEAD -- src/partial_json_parser/version.py; then | |
| echo "CHANGED=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "CHANGED=true" >> $GITHUB_OUTPUT | |
| fi | |
| outputs: | |
| CHANGED: ${{ steps.changes-check.outputs.CHANGED }} | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: diff | |
| environment: release | |
| if: needs.diff.outputs.CHANGED == 'true' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up python | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: 3.13 | |
| - name: Build package | |
| run: | | |
| python src/overrides.py 3.6 | |
| uv build | |
| - name: Create GitHub release | |
| run: | | |
| VERSION="$(grep -m1 -oP '^__version__\s*=\s*"\K[^"]+' src/partial_json_parser/version.py)" | |
| gh release create v$VERSION --title=v$VERSION --generate-notes dist/* | |
| - name: Publish to PyPI | |
| if: ${{ github.repository == 'promplate/partial-json-parser' }} | |
| run: uv publish |