Skip to content

Merge pull request #273 from DavidT3/deps/updateAstropy #20

Merge pull request #273 from DavidT3/deps/updateAstropy

Merge pull request #273 from DavidT3/deps/updateAstropy #20

# 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
# Sets up PIP properly
- 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
# Builds the module
- 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
with:
repository-url: https://test.pypi.org/legacy/