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

CDpypi #26

Closed
wants to merge 3 commits into from
Closed
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
43 changes: 43 additions & 0 deletions .github/workflows/buildwheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build Wheel and source tarball
on:
# Creates a reusable workflow
workflow_call:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
uses: ./.github/workflows/ci-test.yml
build-and-upload:
name: Build and upload
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
MaxOstrowski marked this conversation as resolved.
Show resolved Hide resolved

- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user

- name: Build a binary wheel and a source tarball
run: >-
python3 -m
build
--sdist
--wheel
--outdir dist/
.

- name: Upload binary wheel
uses: actions/upload-artifact@v4
with:
name: wheel
path: dist/
5 changes: 5 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Run CI tests

on:
# Creates a reusable workflow
workflow_call:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Runs the workflow when adding to the main branch
push:
branches:
- main
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish to Pypi

on:
push:
tags:
- v*.*.*

jobs:
build:
uses: ./.github/workflows/buildwheel.yml
pypi-publish:
name: Publish to PyPI
needs: [build]
permissions:
id-token: write
environment: release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: wheel
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
27 changes: 27 additions & 0 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish to TestPypi

on:
# Creates a reusable workflow
workflow_call:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/buildwheel.yml
test-publish:
name: Publish to TestPyPI
needs: [build]
permissions:
id-token: write
environment: test-release
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: wheel
path: dist
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
15 changes: 15 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ python -m pipx install pre-commit
pre-commit install
```

## Deployment

To release this project on (test.)pypi.org please follow these instructions:

Long version:
https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
TL;DR
- create a github environmnent (Github->Your Project->Settings->Environments) with the safety regulations you prefer, e.g. restriction
to a fixed set of branches like "test_release" or manual confirmation
This step is important to prevent other people from releasing new versions on accident
- create a [test.]pypi.org account (enable 2fa)
- create a project with the same name
- add the formerly created github environment
- run the respective CI scripts either manually (test.pypi.org) or by tagging a release version (pypi.org)

[nox]: https://nox.thea.codes/en/stable/index.html
[pipx]: https://pypa.github.io/pipx/
[pre]: https://pre-commit.com/
Expand Down
Loading