-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GH Action - Publish Python Package (#30)
* feat: set up Python package publishing GH Action * docs: describe the new release process * fix: aligns spacing and order of Workflow job configs * chore: specify Python version to 3.10
- Loading branch information
Showing
5 changed files
with
152 additions
and
50 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,91 @@ | ||
# Triggered on push events to the main branch. | ||
# Publishes the package to PyPI only on tag pushes. | ||
|
||
name: 🐍 📦 Publish Python distribution to PyPI and TestPyPI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
build: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 🐍 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Setup Poetry 📚 | ||
uses: Gr1N/setup-poetry@v8 | ||
|
||
- name: Build distribution 📦 | ||
run: poetry build | ||
|
||
- name: Store the distribution artifact 🥶 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
publish-to-pypi: | ||
name: Publish distro to PyPI 🐍 📦 | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
|
||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
|
||
environment: | ||
name: prod | ||
url: https://pypi.org/p/dbt-datadict | ||
|
||
permissions: | ||
id-token: write | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
|
||
publish-to-testpypi: | ||
name: Publish distro to TestPyPI 🐍 📦 | ||
|
||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
|
||
environment: | ||
name: test | ||
url: https://test.pypi.org/p/dbt-datadict | ||
|
||
permissions: | ||
id-token: write | ||
|
||
steps: | ||
- 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/ | ||
password: ${{ secrets.PYPI_TOKEN }} | ||
skip-existing: true |
File renamed without changes.
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,14 @@ | ||
# Package Release Process | ||
|
||
1. Once you have made all the necessary changes to the package, update the version in the `pyproject.toml` file by running the following command, where the version specified is in line with the [PyPA Version Specifiers specification](https://packaging.python.org/en/latest/specifications/version-specifiers/#version-specifiers). | ||
|
||
```bash | ||
poetry version <version> | ||
``` | ||
|
||
> **Hint** | ||
> Run `poetry version --help` to see Poetry's options for automatic SemVer version bumping. | ||
2. Commit the changes to the `pyproject.toml` file. | ||
3. Once the `main` branch is in a release-ready state, create a new GitHub Release with a new tag `v<version>`. The release notes should include a summary of the changes made in the release. | ||
4. Creating the release will trigger a [GitHub Action](../.github/workflows/publish.yml) that will publish the package to PyPI. Validate that the package has been published by checking the GH Action and the [PyPI project page](https://pypi.org/p/dbt-datadict). |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.