-
Notifications
You must be signed in to change notification settings - Fork 1
17 python release #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
619012a
shared release workflow
chrisdicaprio 887ba5b
add mkdocs
chrisdicaprio 2528323
dummy documentation for testing
chrisdicaprio 3f39b6b
working directory arg; release
chrisdicaprio 1631953
test release workflow
chrisdicaprio 105c100
remove TODO comments
chrisdicaprio 398e69c
add changelog
chrisdicaprio 33654b7
use GNS changelog action
chrisdicaprio ce95b98
comment out job env and defaults
chrisdicaprio 8e9b930
checkout repo before using working-directory
chrisdicaprio 7f755e9
change changelog path
chrisdicaprio 0d91312
explicit working dir for changelog
chrisdicaprio ccf0e85
x
chrisdicaprio 3fb9dad
optional version
chrisdicaprio 0a20ec8
conitidional inside step
chrisdicaprio e43c186
remove if statements
chrisdicaprio 92d5f6b
add fi
chrisdicaprio 3ddc559
set env var
chrisdicaprio fdeb714
swap if statement
chrisdicaprio 34f9c53
set output of echo
chrisdicaprio 630ccf7
fix if
chrisdicaprio 8d1015e
test version
chrisdicaprio 2db9f20
fix echo
chrisdicaprio 922d28e
fix changelog
chrisdicaprio 464fd21
explicit paths
chrisdicaprio c6baa2b
only release if there is a tag
chrisdicaprio 6743ca2
fix if
chrisdicaprio 3aab2dc
fix if again
chrisdicaprio 3802972
pypi only if tag
chrisdicaprio 70b0c5f
remove files use for testing release workflow
chrisdicaprio a2598f4
remove release test
chrisdicaprio 08b54ac
remove components used for testing
chrisdicaprio 91136b7
remove mkdocs
chrisdicaprio ee9bc72
split publication/deployment of docs from release/PyPI distribution
chrisdicaprio ef478e3
deploy docs
chrisdicaprio b9f855d
change name
chrisdicaprio 3d68292
checkout repo
chrisdicaprio 85b015a
setup venv
chrisdicaprio 9430caf
white space
chrisdicaprio 66ee2f3
add timeout and env
chrisdicaprio bc56e9f
split out setup python, poetry, and install package for sharing
chrisdicaprio 749896f
move python install to actions
chrisdicaprio b329b49
actions/checkout
chrisdicaprio 5272d6c
defaults
chrisdicaprio e550991
fix defaults
chrisdicaprio 35f311e
remove defaults
chrisdicaprio 20e289c
add shell to all steps
chrisdicaprio a344898
only shell with run
chrisdicaprio 875824e
working directory
chrisdicaprio 7929ded
cd to working dir
chrisdicaprio 0ee8ee8
remove working-dir variable from steps
chrisdicaprio 5f59bd3
fix cd
chrisdicaprio 3c36a89
fix bug
chrisdicaprio b56bc39
cd every step
chrisdicaprio 2a0f29a
set env
chrisdicaprio c080bed
a little test
chrisdicaprio 01cbd18
use working-directory for run
chrisdicaprio 775a1eb
use composite action
chrisdicaprio 5f4bae5
reference action by repo
chrisdicaprio 9dd547f
reference action by repo
chrisdicaprio 848f0f6
fix small bugs
chrisdicaprio 3bcdae9
boolians in composite actions are actually strings
chrisdicaprio e725d91
remove deprecated set-output, replace with
chrisdicaprio db97a35
retrigger checks
chrisdicaprio 5d3aba0
add timeout, fix typo
chrisdicaprio 74e305c
update changelog
chrisdicaprio f3030d4
switch to main branch
chrisdicaprio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,80 @@ | ||
| name: Setup Python Venv | ||
|
|
||
| # Reusable workflow for Python projects that checks out repo and installs with Poetry | ||
|
|
||
|
|
||
| inputs: | ||
| python-version: | ||
| description: A Python version to use | ||
| required: true | ||
| type: string | ||
| poetry-version: | ||
| description: The poetry version to use | ||
| required: false | ||
| type: string | ||
| working-directory: | ||
| description: The working directory | ||
| required: false | ||
| type: string | ||
| default: . | ||
| delete-poetry-lock: | ||
| description: Delete poetry lock file in order to test against newer versions | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
|
|
||
|
|
||
| #---------------------------------------------- | ||
| # delete poetry.lock file in order to run tests against newer versions | ||
| #---------------------------------------------- | ||
| - name: Delete poetry.lock file | ||
| if: ${{ inputs.delete-poetry-lock == 'true' }} | ||
| shell: bash | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: | | ||
| rm ./poetry.lock | ||
| echo "::Warning tile=poetry.lock::Poetry.lock is deleted in this workflow run. You might have to do this too when reproducing build errors." | ||
|
|
||
| #---------------------------------------------- | ||
| # install Python | ||
| #---------------------------------------------- | ||
| - uses: actions/setup-python@v5 | ||
| id: pythonInstallStep | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
|
|
||
| #---------------------------------------------- | ||
| # install Poetry | ||
| #---------------------------------------------- | ||
| - name: Install and configure Poetry | ||
| uses: GNS-Science/install-poetry@main | ||
| with: | ||
| version: ${{ inputs.poetry-version }} | ||
| virtualenvs-create: true | ||
| virtualenvs-in-project: true | ||
| installer-parallel: true | ||
|
|
||
| #---------------------------------------------- | ||
| # load cached venv if cache exists | ||
| #---------------------------------------------- | ||
| - name: Load cached venv | ||
| id: cached-poetry-dependencies | ||
| if: ${{ inputs.delete-poetry-lock == 'false' }} | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ inputs.working-directory }}/.venv | ||
| key: venv-${{ runner.os }}-${{ steps.pythonInstallStep.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}-python-run-tests | ||
|
|
||
| #---------------------------------------------- | ||
| # install dependencies if cache does not exist | ||
| #---------------------------------------------- | ||
| - name: Install dependencies | ||
| shell: bash | ||
| if: inputs.delete-poetry-lock || steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
| working-directory: ${{ inputs.working-directory }} | ||
| run: | ||
| poetry install --no-interaction --no-root --with dev --all-extras |
This file contains hidden or 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,86 @@ | ||
| name: Python Deploy Docs | ||
|
|
||
| # Publishes documentation for a python package to GitHub pages. Uses `mkdocs` for building documentation. Would commonly | ||
| # be one of two jobs along with with Python Release Workflow in a repo workflow triggered by e.g. tagging a version. | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| python-version: | ||
| description: The python version to use | ||
| required: true | ||
| type: string | ||
| default: "3.10" | ||
| poetry-version: | ||
| description: The poetry version to use | ||
| required: false | ||
| type: string | ||
| default: "latest" | ||
| working-directory: | ||
| description: The working directory | ||
| required: false | ||
| type: string | ||
| default: . | ||
| timeout-minutes: | ||
| description: Maximum runtime in minutes | ||
| required: false | ||
| type: number | ||
| default: 10 | ||
|
|
||
|
|
||
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
| permissions: | ||
| contents: write | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
| # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
| concurrency: | ||
| group: "pages" | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| deploy: | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: ${{ inputs.timeout-minutes }} | ||
| defaults: | ||
| run: | ||
| working-directory: ${{ inputs.working-directory }} | ||
|
|
||
| steps: | ||
|
|
||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: install_package | ||
| uses: GNS-Science/nshm-github-actions/.github/actions/python-install@main | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
| poetry-version: ${{ inputs.poetry-version }} | ||
| working-directory: ${{ inputs.working-directory }} | ||
|
|
||
| #---------------------------------------------- | ||
| # build documentation | ||
| #---------------------------------------------- | ||
| - name: build documentation | ||
| run: | | ||
| poetry run mkdocs build | ||
|
|
||
| #---------------------------------------------- | ||
| # package and upload artifact for deployment to GitHub Pages | ||
| #---------------------------------------------- | ||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v4 | ||
| with: | ||
| path: ${{ inputs.working-directory }}/site | ||
|
|
||
|
|
||
| #---------------------------------------------- | ||
| # deploy page | ||
| #---------------------------------------------- | ||
| - name: Deploy Docs to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 |
This file contains hidden or 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,111 @@ | ||
| name: Python Release | ||
|
|
||
| # Creates a GitHub release and publishes the package to PyPI. Would commonly be one of two jobs along | ||
| # with with Python Deploy Docs in a repo workflow triggered by e.g. tagging a version. | ||
| # | ||
| # Requires the secret `PYPI_API_TOKEN`. | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| python-version: | ||
| description: The python version to use | ||
| required: true | ||
| type: string | ||
| default: "3.10" | ||
| poetry-version: | ||
| description: The poetry version to use | ||
| required: false | ||
| type: string | ||
| default: "latest" | ||
| working-directory: | ||
| description: The working directory | ||
| required: false | ||
| type: string | ||
| default: . | ||
| timeout-minutes: | ||
| description: Maximum runtime in minutes | ||
| required: false | ||
| type: number | ||
| default: 10 | ||
|
|
||
|
|
||
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
| # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
| concurrency: | ||
| group: "pages" | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| release: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: ${{ inputs.timeout-minutes }} | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| working-directory: ${{ inputs.working-directory }} | ||
| steps: | ||
|
|
||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: install_package | ||
| uses: GNS-Science/nshm-github-actions/.github/actions/python-install@main | ||
| with: | ||
| python-version: ${{ inputs.python-version }} | ||
| poetry-version: ${{ inputs.poetry-version }} | ||
| working-directory: ${{ inputs.working-directory }} | ||
|
|
||
| #---------------------------------------------- | ||
| # get version | ||
| #---------------------------------------------- | ||
| - name: Get version from tag | ||
| id: tag_name | ||
| run: | | ||
| echo name=current_version::${GITHUB_REF#refs/tags/v} >> "$GITHUB_OUTPUT" | ||
| shell: bash | ||
|
|
||
| #---------------------------------------------- | ||
| # get changelog entry | ||
| #---------------------------------------------- | ||
| - name: Get Changelog Entry | ||
|
chrisdicaprio marked this conversation as resolved.
|
||
| id: changelog_reader | ||
| uses: GNS-Science/changelog-reader-action@master | ||
| with: | ||
| validation_depth: 10 | ||
| version: ${{ steps.tag_name.outputs.current_version }} | ||
| path: ${{ inputs.working-directory }}/CHANGELOG.md | ||
|
|
||
| #---------------------------------------------- | ||
| # build wheels and tarball | ||
| #---------------------------------------------- | ||
| - name: Build wheels and source tarball | ||
| run: >- | ||
| poetry build | ||
|
|
||
| - name: show temporary files | ||
| run: >- | ||
| ls -l | ||
|
|
||
| #---------------------------------------------- | ||
| # create GitHub release | ||
| #---------------------------------------------- | ||
| - name: create github release | ||
| id: create_release | ||
| uses: GNS-Science/action-gh-release@master | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| body: ${{ steps.changelog_reader.outputs.changes }} | ||
| files: ${{ inputs.working-directory }}/dist/*.whl | ||
| draft: false | ||
| prerelease: false | ||
|
|
||
| #---------------------------------------------- | ||
| # publish to PyPI | ||
| #---------------------------------------------- | ||
| - name: publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
| with: | ||
| user: __token__ | ||
| password: ${{ secrets.PYPI_API_TOKEN }} | ||
| skip-existing: true | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -23,3 +23,38 @@ jobs: | |
| python-versions: "['3.9', '3.10', '3.11']" | ||
| secrets: inherit | ||
| ``` | ||
|
|
||
| ### [Python Release Workflow](./.github/workflows/python-release.yml) | ||
|
|
||
| Creates a GitHub release and publishes the package to PyPI. Would commonly be one of two jobs along with with Python Deploy Docs in a repo workflow triggered by e.g. tagging a version. | ||
|
|
||
| Requires the secret `PYPI_API_TOKEN`. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add this to the top of the yml file too, to be sure. |
||
|
|
||
| Example use: | ||
|
|
||
| ```yml | ||
| jobs: | ||
| release-and-distribute: | ||
| uses: GNS-Science/nshm-github-actions/.github/workflows/python-release.yml@main | ||
| with: | ||
| python-version: '3.12' | ||
| secrets: inherit | ||
| ``` | ||
|
|
||
|
|
||
| ### [Python Deploy Docs Workflow](./.github/workflows/python-deploy-docs.yml) | ||
|
|
||
| Publishes documentation for a python package to GitHub pages. Uses `mkdocs` for building documentation. Would commonly be one of two jobs along with with Python Release Workflow in a repo workflow triggered by e.g. tagging a version. | ||
|
|
||
| Requires that the branch or tag you want to use has permission to do so in the `github-pages` environment; see [GitHub documentation](https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments). | ||
|
|
||
| Example use: | ||
|
|
||
| ```yml | ||
| jobs: | ||
| deploy-docs: | ||
| uses: GNS-Science/nshm-github-actions/.github/workflows/python-deploy-docs.yml@main | ||
| with: | ||
| python-version: '3.12' | ||
| secrets: inherit | ||
| ``` | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.