Skip to content

Commit

Permalink
chore: Use PyPI trusted publishers (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon authored May 8, 2024
1 parent 452c1fd commit d5fa9a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
51 changes: 25 additions & 26 deletions .github/workflows/release_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
name: Upload Python Package
name: Build and publish

on:
release:
types: [created]
push:

jobs:
build_deploy:

build:
name: Build wheel and sdist
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
ref: ${{ github.ref }}
- uses: hynek/build-and-inspect-python-package@v2

publish:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
environment:
name: publishing
url: https://pypi.org/p/meltanolabs-target-postgres
needs: build
permissions:
contents: write
id-token: write

steps:
- uses: actions/download-artifact@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Build package
run: |
poetry self add "poetry-dynamic-versioning[plugin]"
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry dynamic-versioning --no-cache
poetry build
- name: Upload wheel to release
uses: svenstaro/upload-release-action@v2
name: Packages
path: dist
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.whl
tag: ${{ github.ref }}
overwrite: true
file_glob: true
- name: Deploy to PyPI
run: |
poetry publish -r testpypi -u "__token__" -p "${{ secrets.TEST_PYPI_TOKEN }}"
poetry publish -u "__token__" -p "${{ secrets.POSTGRES_PYPI_TOKEN }}"
- uses: pypa/[email protected]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module = ["sshtunnel"]
ignore_missing_imports = true

[build-system]
requires = ["poetry-core==1.8.1", "poetry-dynamic-versioning==1.2.0"]
requires = ["poetry-core==1.9.0", "poetry-dynamic-versioning==1.3.0"]
build-backend = "poetry_dynamic_versioning.backend"

[tool.poetry.scripts]
Expand Down

0 comments on commit d5fa9a2

Please sign in to comment.