Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate publish and publish-pr workflows #48

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading