diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index efb5bfc..327a1bb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,6 +1,8 @@ name: Publish to PyPI + on: - workflow_dispatch: + release: + types: [published] jobs: publish: @@ -8,26 +10,15 @@ jobs: environment: pypi permissions: id-token: write - contents: write steps: - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v5 + with: + ref: ${{ github.event.release.tag_name }} - - name: Get version from pyproject.toml - id: get_version - run: | - VERSION=$(python -c "import tomllib; data=tomllib.load(open('pyproject.toml','rb')); print(data['project']['version'])") - echo "version=$VERSION" >> $GITHUB_OUTPUT + - uses: astral-sh/setup-uv@v5 - name: Build run: uv build - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 - with: - tag_name: v${{ steps.get_version.outputs.version }} - name: v${{ steps.get_version.outputs.version }} - generate_release_notes: true - - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7c9dd46 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + contents: write + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v5 + + - name: Get version from pyproject.toml + id: get_version + run: | + VERSION=$(python -c "import tomllib; data=tomllib.load(open('pyproject.toml','rb')); print(data['project']['version'])") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Build + run: uv build + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ steps.get_version.outputs.version }} + name: v${{ steps.get_version.outputs.version }} + generate_release_notes: true + files: dist/* \ No newline at end of file