Skip to content

Commit

Permalink
Separate publish and publish-pr workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
lmelninkas committed Apr 22, 2024
1 parent f0cd771 commit 1aece2a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 14 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/pr-publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Publish to Test PyPi

on: # yamllint disable-line rule:truthy
pull_request:
types:
- labeled
- opened
- synchronize
workflow_dispatch:

jobs:
build:
if: |
contains( github.event.pull_request.labels.*.name, 'publish-pr') ||
contains( github.event.pull_request.labels.*.name, 'build-pr')
name: Build package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install build dependencies
run: python -m pip install poetry==1.4.2 poetry-dynamic-versioning==1.2.0
- name: Install project
run: poetry install
- name: Build Python package
run: poetry build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-testpypi:
if: contains( github.event.pull_request.labels.*.name, 'publish-pr')
name: Publish package to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/pyap2

permissions:
id-token: write

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
14 changes: 0 additions & 14 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
name: Publish to PyPi

on: # yamllint disable-line rule:truthy
push:
branches:
- master
- main
pull_request:
types:
- labeled
- opened
- synchronize
release:
types:
- published
workflow_dispatch:

jobs:
build:
if: |
contains( github.event.pull_request.labels.*.name, 'publish-pr') ||
contains( github.event.pull_request.labels.*.name, 'build-pr')
name: Build package
runs-on: ubuntu-latest
steps:
Expand All @@ -43,7 +31,6 @@ jobs:
path: dist/

publish-to-pypi:
if: contains( github.event.pull_request.labels.*.name, 'publish-pr')
name: Publish package to PyPI
needs:
- build
Expand All @@ -66,7 +53,6 @@ jobs:
uses: pypa/gh-action-pypi-publish@release/v1

publish-to-testpypi:
if: contains( github.event.pull_request.labels.*.name, 'publish-pr')
name: Publish package to TestPyPI
needs:
- build
Expand Down

0 comments on commit 1aece2a

Please sign in to comment.