|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*.*.*' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Tag to release' |
| 11 | + required: true |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + create-github-release: |
| 19 | + name: Create GitHub Release |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + tag_name: ${{ steps.set-tag.outputs.tag }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v6 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + |
| 28 | + - name: Set tag name |
| 29 | + id: set-tag |
| 30 | + run: echo "tag=${{ github.event.inputs.tag || github.ref_name }}" >> "$GITHUB_OUTPUT" |
| 31 | + |
| 32 | + - name: Install uv |
| 33 | + uses: astral-sh/setup-uv@v7 |
| 34 | + with: |
| 35 | + python-version: "3.12" |
| 36 | + enable-cache: true |
| 37 | + |
| 38 | + - name: Check version consistency |
| 39 | + run: | |
| 40 | + VERSION=$(grep -m 1 'version = ' pyproject.toml | cut -d '"' -f 2) |
| 41 | + TAG=${{ steps.set-tag.outputs.tag }} |
| 42 | + CLEAN_TAG=${TAG#v} |
| 43 | + if [ "$VERSION" != "$CLEAN_TAG" ]; then |
| 44 | + echo "Version in pyproject.toml ($VERSION) does not match tag ($TAG)" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | +
|
| 48 | + - name: Build distribution |
| 49 | + run: uv build |
| 50 | + |
| 51 | + - name: Create GitHub Release |
| 52 | + uses: softprops/action-gh-release@v2 |
| 53 | + with: |
| 54 | + tag_name: ${{ steps.set-tag.outputs.tag }} |
| 55 | + name: ${{ steps.set-tag.outputs.tag }} |
| 56 | + generate_release_notes: true |
| 57 | + draft: false |
| 58 | + prerelease: ${{ contains(steps.set-tag.outputs.tag, 'a') || contains(steps.set-tag.outputs.tag, 'b') || contains(steps.set-tag.outputs.tag, 'rc') }} |
| 59 | + files: | |
| 60 | + dist/*.whl |
| 61 | + dist/*.tar.gz |
| 62 | + env: |
| 63 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + |
| 65 | + publish-to-pypi: |
| 66 | + name: Publish to PyPI |
| 67 | + needs: [create-github-release] |
| 68 | + runs-on: ubuntu-latest |
| 69 | + environment: |
| 70 | + name: pypi |
| 71 | + url: https://pypi.org/project/lsap/ |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v6 |
| 74 | + |
| 75 | + - name: Install uv |
| 76 | + uses: astral-sh/setup-uv@v7 |
| 77 | + with: |
| 78 | + python-version: "3.12" |
| 79 | + enable-cache: true |
| 80 | + |
| 81 | + - name: Build distribution |
| 82 | + run: uv build |
| 83 | + |
| 84 | + - name: Publish to PyPI |
| 85 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments