diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b89d4a6..55f2015 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,6 +1,9 @@ name: release -on: push +on: + push: + branches: + - main permissions: contents: write diff --git a/template/{% if enable_github_action %}.github{% endif%}/workflows/{% if publish_to_pypi %}release.yaml{% endif %}.jinja b/template/{% if enable_github_action %}.github{% endif%}/workflows/release.yaml.jinja similarity index 57% rename from template/{% if enable_github_action %}.github{% endif%}/workflows/{% if publish_to_pypi %}release.yaml{% endif %}.jinja rename to template/{% if enable_github_action %}.github{% endif%}/workflows/release.yaml.jinja index 936b406..4d298ac 100644 --- a/template/{% if enable_github_action %}.github{% endif%}/workflows/{% if publish_to_pypi %}release.yaml{% endif %}.jinja +++ b/template/{% if enable_github_action %}.github{% endif%}/workflows/release.yaml.jinja @@ -41,39 +41,3 @@ jobs: github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} git_committer_name: "github-actions" git_committer_email: "actions@users.noreply.github.com" - - outputs: - released: {% raw %}${{ steps.release.outputs.released || 'false' }}{% endraw %} - tag: {% raw %}${{ steps.release.outputs.tag }}{% endraw %} - - - publish: - runs-on: ubuntu-latest - needs: release - if: {% raw %}${{ needs.release.outputs.released == 'true' }}{% endraw %} - - environment: - name: pypi - url: https://pypi.org/p/{{ project_name }} - - permissions: - contents: write - {# IMPORTANT: this permission is mandatory for Trusted Publishing #} - id-token: write - - steps: - - name: Check out at new tag - uses: actions/checkout@v4 - with: - ref: {% raw %}${{ needs.release.outputs.tag }}{% endraw %} - - - name: Set up the environment - uses: ./.github/actions/setup-python-env - - - name: Build Package - run: make build - - - name: Publish package distributions to PyPI - uses: pypa/gh-action-pypi-publish@v1.13.0 - with: - packages-dir: dist diff --git a/template/{% if enable_github_action %}.github{% endif%}/workflows/{% if publish_to_pypi %}publish.yaml{% endif %}.jinja b/template/{% if enable_github_action %}.github{% endif%}/workflows/{% if publish_to_pypi %}publish.yaml{% endif %}.jinja new file mode 100644 index 0000000..bf8b826 --- /dev/null +++ b/template/{% if enable_github_action %}.github{% endif%}/workflows/{% if publish_to_pypi %}publish.yaml{% endif %}.jinja @@ -0,0 +1,38 @@ +name: publish + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + + permissions: + contents: write + {# IMPORTANT: this permission is mandatory for Trusted Publishing #} + id-token: write + + environment: + name: pypi + url: https://pypi.org/p/{{ project_name }} + + steps: + - name: Check out at new tag + uses: actions/checkout@v4 + with: + ref: {% raw %}${{ github.event.release.tag_name }}{% endraw %} + + - name: Set up the environment + uses: ./.github/actions/setup-python-env + + - name: Build Package + run: make build + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@v1.13.0 + with: + packages-dir: dist