Skip to content

Commit

Permalink
Closes #104 (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulvxx authored Apr 22, 2024
1 parent 7ad4ef4 commit 57c35a3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 76 deletions.
31 changes: 6 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: Build and Publish
# This workflow builds the current repository into a distributable package.
# For more information on using GitHub Actions for building and testing Python projects,
# visit: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

name: Build

on:
push:
Expand All @@ -22,31 +26,8 @@ jobs:
python -m pip install --upgrade pip
pip install bumpversion build twine
# I wasn't able to find a way to override our current branch protection
# but essentially that is the issue why automation is unable to update the version number
# each time

#- name: Configure Git user
# run: |
# git config --local user.email "action@github.com"
# git config --local user.name "GitHub Action"

#- name: Bump patch version
# run: bumpversion --verbose patch

#- name: Push changes
# run: |
# git push --quiet https://$ {{ secrets.GH_PAT }}@github.com/$ {{ github.repository }} HEAD:$ {{ github.ref }}
# git push --tags --quiet https://$ {{ secrets.GH_PAT }}@github.com/$ {{ github.repository }} HEAD:$ {{ github.ref }}
# env:
# GH_PAT: $ {{ secrets.GH_PAT }}

# Run bash script to build the package
- name: Build Package
run: |
./build.sh
#- name: Publish Package
# env:
# PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
# run: |
# twine upload dist/* --verbose --non-interactive --repository testpypi --username __token__ --password $PYPI_API_TOKEN
51 changes: 0 additions & 51 deletions .github/workflows/python-package.txt

This file was deleted.

69 changes: 69 additions & 0 deletions pyPI_guide.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
The Python Package Index, or PyPI, is a repository for Python packages that allows users to upload, modify, and install packages using pip. Currently, the pyMGM project is on a "tester" version of PyPI called TestPyPI. This is a "beta" packaging index intended for incomplete or test versions of packages.

The instructions below will guide you through on how to transfer the current Python Project from TestPyPI over to the real index (PyPI)

You need to follow the following instructions to be able to publish Python Packages to the packaging index. This will enable anyone (or a select number of users in case of a private package) to pip install your package.


1. Ensure pip is installed by running:

> pip --version
pip 24.0 from C:\Python312\Lib\site-packages\pip (python 3.12)

Example output: pip 24.0 from C:\Python312\Lib\site-packages\pip (python 3.12)
Note: This applies to both Windows, Mac, and Linux.If pip is not installed, follow the installation instructions for your OS.

If pip is not installed, follow the instructions on this link below to install it, for your OS.

https://pip.pypa.io/en/stable/installation/

2. If you are new to packaging Python projects, this might be a good start:

https://packaging.python.org/en/latest/tutorials/packaging-projects/

3. You will need to register for an account at https://pypi.org/.

4. Once registered, go to your account settings.

5. Navigate to 'Two factor authentication (2FA)' and choose a 2FA method (An authentication Application like Google Duo, or a Security Device such as a USB key supporting 2FA)

6. Go to 'API tokens' and create a new API token. This will be used for publishing your package to pyPI.

7. In your GitHub project, navigate to 'Settings'.

8. Under Settings, find 'Secrets' or 'Secrets and variables'. Click on that.

9. Click on the pencil icon next to 'PYPI_API_TOKEN' to update the secret with the token you generated. Copy/paste the new token's contents into the secret.

10. From the main repository, navigate to '.github/workflows/py-publish.yml'.

11. In the script, find and edit the line responsible for uploading the package:

twine upload dist/* --verbose --non-interactive --repository testpypi --username __token__ --password $PYPI_API_TOKEN

Remove '--repository testpypi' as we are no longer uploading to TestPyPI (by default, twine will upload to PyPI).

as we are no longer uploading to TestPyPI (by default, twine will upload to PyPI).

12. You may wish to navigate to the 'pyproject.toml' configuration file in the main directory, and change the name of the project. Currently it is:

name = "pymgm-test"

You may also wish to update the first version number you aim to publish as well (right after that)


Optional:

13. To verify the pyPI index was set up correctly you can:

a. Enter a new command with whatever tag name you want (ensure you are in the repository presumably locally):

> git tag v0.x.x

b. Then push your changes to GitHub

> git push --tags

c. Visit your package page on PyPI to verify that it was published successfully.


0 comments on commit 57c35a3

Please sign in to comment.