-
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.
Merge pull request #269 from DavidT3/pub/getReadyForPyPIPublish
Pub/get ready for py pi publish
- Loading branch information
Showing
3 changed files
with
178 additions
and
4 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,83 @@ | ||
# Created with the help of: | ||
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | ||
# and | ||
# https://medium.com/@VersuS_/automate-pypi-releases-with-github-actions-4c5a9cfe947d | ||
|
||
# This action triggers the second stage of publishing this module. When a new release is created this action will begin. It builds the module, then | ||
# publishes it to the real PyPI index | ||
|
||
|
||
# The overall name of the action | ||
name: Publish DAXA to real PyPI, triggered on creation of release | ||
|
||
# This action triggers when there is a release to the repo, but only when the release is published | ||
on: | ||
release: | ||
types: [published] | ||
|
||
# Now the actual jobs we want the action to do are set up | ||
jobs: | ||
# The only job in this action, building and publishing the DAXA Python module | ||
build-n-publish: | ||
name: Build and publish DAXA | ||
# The build/publishing process runs on latest Ubuntu - not super important what this is for this use case | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/daxa # Replace <package-name> with your PyPI project name | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
# This job has several steps | ||
steps: | ||
# Checks out the master branch and then activates a relatively recent version of Python | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
|
||
- name: Setup the Python install | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
|
||
# The next two chunks set up PIP properly and build the module | ||
- name: Install pypa/build | ||
run: >- | ||
python -m | ||
pip install | ||
build | ||
--user | ||
# This SHOULD set the correct version in setup.py, taken from the tag | ||
- name: Extract tag name | ||
id: tag | ||
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3) | ||
- name: Update version in setup.py | ||
run: >- | ||
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py | ||
- name: Build a binary wheel and source tarball | ||
run: >- | ||
python -m | ||
build | ||
--sdist | ||
--wheel | ||
--outdir dist/ | ||
. | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
|
||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 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,93 @@ | ||
# Created with the help of: | ||
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ | ||
# and | ||
# https://medium.com/@VersuS_/automate-pypi-releases-with-github-actions-4c5a9cfe947d | ||
|
||
# This action triggers the first stage of publishing this module. When a new tag is created and pushed to the remote | ||
# repository, this action will begin. It builds the module, just as it would for an actual PyPI release, then uploads | ||
# it to the Test PyPI index. That way I can test install the package from the test PyPI and not expose the real PyPI | ||
# index to a potentially buggered version. When I verify that it works, a real publishing can be triggered by | ||
# releasing the module. | ||
|
||
# As a reminder to myself, the installation from test PyPI has to be done using this command (THE TEST PYPI PROJECT | ||
# NAME IS DIFFERENT FROM THE ACTUAL NAME, BECAUSE THERE IS ALREADY A 'DAXA' PROJECT ON TEST PYPI): | ||
# pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple daxa-xray | ||
|
||
# The overall name of the action | ||
name: Publish DAXA to test PyPI, triggered on creation of tags | ||
|
||
# This action triggers when there is a push to the repo | ||
on: push | ||
|
||
# Now the actual jobs we want the action to do are setup | ||
jobs: | ||
# The only job in this action, building and publishing the DAXA Python module | ||
build-n-publish: | ||
name: Build and publish DAXA | ||
# I actually only want to run this one if the pushed commit has a tag - I will only do this for new versions of the module | ||
if: startsWith(github.ref, 'refs/tags') | ||
# The build/publishing process runs on latest Ubuntu - not super important what this is for this use case | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: testpypi | ||
url: https://test.pypi.org/p/daxa-xray # Replace <package-name> with your PyPI project name | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
# This job has several steps | ||
steps: | ||
# Checks out the master branch and then activates a relatively recent version of Python | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup the Python install | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
|
||
# The next two chunks set up PIP properly and build the module | ||
- name: Install pypa/build | ||
run: >- | ||
python -m | ||
pip install | ||
build | ||
--user | ||
# This SHOULD set the correct version in setup.py, taken from the tag | ||
- name: Extract tag name | ||
id: tag | ||
run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3) | ||
- name: Update version in setup.py | ||
run: >- | ||
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py | ||
- name: Build a binary wheel and source tarball | ||
run: >- | ||
python -m | ||
build | ||
--sdist | ||
--wheel | ||
--outdir dist/ | ||
. | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
# # Then the module is published to the test PyPI index | ||
# - name: Publish to TestPyPI | ||
# uses: pypa/gh-action-pypi-publish@master | ||
# with: | ||
# password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
# repository_url: https://test.pypi.org/legacy/ | ||
- 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 | ||
|
||
|
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