-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* FIX: repeated version of nbstripout * ADD: PyPI shield * ADD: .lock file * FIX: removed appearance of Python 3.8 * FIX: removed appearance of Python 3.8 * ENH: PR CI Python version 3.8->3.11 * ADD: custom publish action * ENH: readme * ENH: Attempt at splitting TestPyPI & PyPI
- Loading branch information
1 parent
bbd8f6e
commit e265ebe
Showing
4 changed files
with
170 additions
and
24 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,125 @@ | ||
name: "PyPI Poetry Publish" | ||
: # from https://github.com/code-specialist/pypi-poetry-publish/blob/main/action.yaml | ||
description: "Opinionated GitHub action to fully automate publishing packages to any PyPI registry - using Poetry and GitHub releases" | ||
branding: | ||
icon: "package" | ||
color: "blue" | ||
|
||
inputs: | ||
ACCESS_TOKEN: | ||
description: "Access Token for GitHub with write access on the repository" | ||
required: true | ||
PYTHON_VERSION: | ||
description: "Python Version" | ||
required: false | ||
default: "3.10" | ||
PACKAGE_DIRECTORY: | ||
description: "Directory of the package" | ||
required: false | ||
default: "./" | ||
PUBLISH_REGISTRY_PASSWORD: | ||
description: "Password for the user to publish to PyPI. May also be a Token - requires the `PUBLISH_REGISTRY_USERNAME` to be `__token__`" | ||
required: true | ||
PUBLISH_REGISTRY_USERNAME: | ||
description: "The username for the registry. Defaults to __token__" | ||
required: false | ||
default: "__token__" | ||
POETRY_VERSION: | ||
description: "The version of Poetry to use" | ||
required: false | ||
default: "" | ||
POETRY_CORE_VERSION: | ||
description: "The version of Poetry Core to use" | ||
required: false | ||
default: "" | ||
BRANCH: | ||
description: "Branch to publish from" | ||
required: false | ||
default: "main" | ||
POETRY_DEPENDENCY_REGISTRY_URL: | ||
description: "Allows to define a custom registry to be used by Poetry for dependency installation" | ||
required: false | ||
POETRY_DEPENDENCY_REGISTRY_NAME: | ||
description: "The name used for the custom registry in the dependencies" | ||
required: false | ||
POETRY_DEPENDENCY_REGISTRY_USERNAME: | ||
description: "The username for the custom registry" | ||
required: false | ||
POETRY_DEPENDENCY_REGISTRY_PASSWORD: | ||
description: "The password for the custom registry" | ||
required: false | ||
POETRY_DEPENDENCY_REGISTRY_AUTH: | ||
description: "The authentication type for the custom registry" | ||
required: false | ||
default: "http-basic" | ||
PUBLISH_REGISTRY: | ||
description: "The registry to publish to" | ||
required: false | ||
default: "https://upload.pypi.org/legacy/" | ||
UPDATE_CODE_VERSION: | ||
description: "Whether or not to apply the version update in the code" | ||
required: false | ||
default: "true" | ||
PUSH_BRANCH: | ||
description: "Which branch to push the changes to" | ||
required: false | ||
default: "main" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ inputs.BRANCH }} | ||
token: ${{ inputs.ACCESS_TOKEN }} | ||
|
||
- name: Install poetry | ||
run: pip install poetry${{ inputs.POETRY_VERSION != '' && format('=={0}', inputs.POETRY_VERSION) || '' }} poetry-core${{ inputs.POETRY_CORE_VERSION != '' && format('=={0}', inputs.POETRY_CORE_VERSION) || '' }} | ||
shell: bash | ||
|
||
- name: Set up Python ${{ inputs.PYTHON_VERSION }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ inputs.PYTHON_VERSION }} | ||
cache: poetry | ||
check-latest: true | ||
|
||
- name: Set GitHub Tag as Package Version | ||
run: | | ||
sed -i -r 's/__version__ *= *".*"/__version__ = "${{ github.event.release.tag_name }}"/g' ${{ inputs.PACKAGE_DIRECTORY }}__init__.py | ||
sed -i '0,/version =.*/s//version = "'"${{ github.event.release.tag_name }}"'"/' ./pyproject.toml | ||
shell: bash | ||
|
||
- name: Add and Commit Version | ||
run: | | ||
if ${{ inputs.UPDATE_CODE_VERSION }} | ||
then | ||
git checkout -b ${{ inputs.PUSH_BRANCH }} | ||
git add ${{ inputs.PACKAGE_DIRECTORY }}__init__.py ./pyproject.toml | ||
git config user.name 'github-actions[bot]' | ||
git config user.email 'github-actions[bot]@users.noreply.github.com' | ||
git commit -m "Change version to ${{ github.event.release.tag_name }}" --allow-empty | ||
git push origin HEAD:${{ inputs.PUSH_BRANCH }} | ||
fi | ||
shell: bash | ||
|
||
- name: Install dependencies | ||
if: inputs.POETRY_DEPENDENCY_REGISTRY_URL != '' | ||
run: | | ||
poetry config repositories.${{ inputs.POETRY_DEPENDENCY_REGISTRY_NAME }} ${{ inputs.POETRY_DEPENDENCY_REGISTRY_URL }} | ||
poetry config ${{ inputs.POETRY_DEPENDENCY_REGISTRY_AUTH }}.${{ inputs.POETRY_DEPENDENCY_REGISTRY_NAME }} ${{ inputs.POETRY_DEPENDENCY_REGISTRY_USERNAME }} ${{ inputs.POETRY_DEPENDENCY_REGISTRY_PASSWORD }} | ||
poetry install --no-root | ||
shell: bash | ||
|
||
- name: Install dependencies | ||
if: inputs.POETRY_DEPENDENCY_REGISTRY_URL == '' | ||
run: | | ||
poetry install --no-root | ||
shell: bash | ||
|
||
- name: Build and Publish | ||
run: | | ||
poetry config repositories.publish ${{ inputs.PUBLISH_REGISTRY }} | ||
poetry publish -p ${{ inputs.PUBLISH_REGISTRY_PASSWORD }} -u ${{ inputs.PUBLISH_REGISTRY_USERNAME }} -r publish --build | ||
shell: bash |
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,21 @@ | ||
name: Build and publish choice-learn | ||
|
||
on: | ||
release: | ||
types: [ published ] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish-service-client-package: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Publish choice-learn on TestPyPI | ||
uses: ./.github/actions/publish | ||
with: | ||
PACKAGE_DIRECTORY: "./choice_learn/" | ||
PYTHON_VERSION: "3.9" | ||
PUBLISH_REGISTRY_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }} | ||
PUBLISH_REGISTRY_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }} | ||
PUBLISH_REGISTRY: "https://test.pypi.org/simple/" | ||
UPDATE_CODE_VERSION: TEST_PYPI_USERNAME | ||
PUSH_BRANCH: release_${{ github.event.release.tag_name }} |
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