-
Notifications
You must be signed in to change notification settings - Fork 8
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 #70 from omicsNLP/pypi-release-workflow
Add workflow to publish on PyPI
- Loading branch information
Showing
4 changed files
with
85 additions
and
7 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,22 @@ | ||
name: Set up | ||
description: Set up Python environment and install dependencies | ||
inputs: | ||
python-version: | ||
description: The Python version to use | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install Poetry | ||
shell: bash | ||
run: pipx install poetry | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
cache: poetry | ||
|
||
- name: Install dependencies | ||
shell: bash | ||
run: poetry install |
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,60 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/ci.yml | ||
|
||
# If tests are successful, we build the wheel and push it to the release | ||
build-wheel: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/setup | ||
with: | ||
python-version: '3.13' | ||
|
||
- name: Check package version matches tag | ||
run: | | ||
pkgver=$(python -c "import autocorpus; print(autocorpus.__version__, end='')") | ||
# NB: tag name must be prefixed by "v" (the default for GitHub Releases) | ||
test v$pkgver = ${{ github.ref_name }} | ||
- name: Build package | ||
run: poetry build | ||
|
||
# Upload files as test artifact (to be retrieved later) | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
path: dist/* | ||
|
||
# Publish files as release artifacts | ||
- uses: softprops/action-gh-release@v2 | ||
with: | ||
files: dist/* | ||
|
||
# If all goes well, publish to PyPI | ||
publish-pypi: | ||
needs: build-wheel | ||
name: Publish to PyPI | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write | ||
|
||
steps: | ||
- name: Download wheel and sdist artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: artifact | ||
path: dist | ||
|
||
- name: Display structure of downloaded files | ||
run: ls -R dist | ||
|
||
- name: Publish package distributions 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