-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
93 additions
and
0 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,93 @@ | ||
name: Python CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: write-all | ||
|
||
jobs: | ||
build: | ||
# -------- https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
# -------- https://github.com/actions/checkout | ||
# check out your repository files onto the runner, so that the workflow can access them | ||
- uses: actions/checkout@v4 | ||
|
||
# -------- https://github.com/actions/setup-python | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12.0" | ||
|
||
# -------- | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install black pytest | ||
pip install -r requirements.txt | ||
# -------- | ||
- name: Format with black | ||
run: | | ||
black . --line-length=128 | ||
- name: Commit changes | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
add: '*.py' | ||
author_name: GitHub Actions | ||
author_email: [email protected] | ||
message: "Formatted code with black." | ||
default_author: github_actor | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# -------- build -------- | ||
- name: Install pypa/build | ||
run: | | ||
python -m pip install build --user | ||
- name: Build a binary wheel and a source tarball | ||
run: | | ||
pip install --upgrade wheel | ||
python -m build | ||
- name: Install twine | ||
run: pip install twine | ||
|
||
- name: Check the distribution with twine | ||
run: twine check dist/* | ||
|
||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
# -------- pypi -------- | ||
publish-to-pypi: | ||
name: Publish Python 🐍 distribution 📦 to PyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-20.04 | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/MetricDB | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
|
||
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 |