forked from potassco/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create CD files for auto publishing on [test.]pypi.org
- Loading branch information
1 parent
0c319d9
commit 70eed9c
Showing
5 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
||
- 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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Publish to Pypi | ||
|
||
on: | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
To be able 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) | ||
|