Skip to content

Commit

Permalink
feat(templates): Added an optional GitHub workflow to publish to PyPI…
Browse files Browse the repository at this point in the history
… with trusted publishers
  • Loading branch information
edgarrmondragon committed May 14, 2024
1 parent 8e4172b commit 868adc0
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 0 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ repos:
cookiecutter/.*/meltano.yml|
cookiecutter/.*/.pre-commit-config.yaml|
cookiecutter/.*/dependabot.yml|
cookiecutter/.*/build.yml|
cookiecutter/.*/test.yml
)$
- id: end-of-file-fixer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
push:

permissions:
contents: write # Needed to upload artifacts to the release
id-token: write # Needed for OIDC PyPI publishing

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build]
## TODO: optionally provide the name of the environment for the trusted
## publisher on PyPI
## https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
# environment: pypi
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Upload wheel to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: {{ '${{secrets.GITHUB_TOKEN}}' }}
file: dist/*.whl
tag: {{ '${{github.ref}}' }}
overwrite: true
file_glob: true

- name: Publish
## TODO: create a trusted publisher on PyPI
## https://docs.pypi.org/trusted-publishers/
uses: pypa/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
push:

permissions:
contents: write # Needed to upload artifacts to the release
id-token: write # Needed for OIDC PyPI publishing

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build]
## TODO: optionally provide the name of the environment for the trusted
## publisher on PyPI
## https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
# environment: pypi
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Upload wheel to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: {{ '${{secrets.GITHUB_TOKEN}}' }}
file: dist/*.whl
tag: {{ '${{github.ref}}' }}
overwrite: true
file_glob: true

- name: Publish
## TODO: create a trusted publisher on PyPI
## https://docs.pypi.org/trusted-publishers/
uses: pypa/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Release

on:
push:

permissions:
contents: write # Needed to upload artifacts to the release
id-token: write # Needed for OIDC PyPI publishing

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2

publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build]
## TODO: optionally provide the name of the environment for the trusted
## publisher on PyPI
## https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment
# environment: pypi
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
with:
name: Packages
path: dist
- name: Upload wheel to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: {{ '${{secrets.GITHUB_TOKEN}}' }}
file: dist/*.whl
tag: {{ '${{github.ref}}' }}
overwrite: true
file_glob: true

- name: Publish
## TODO: create a trusted publisher on PyPI
## https://docs.pypi.org/trusted-publishers/
uses: pypa/[email protected]

0 comments on commit 868adc0

Please sign in to comment.