Skip to content

Commit

Permalink
commit flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Don-Yin committed Aug 5, 2024
1 parent 41694bf commit dd433cb
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/pypi.yml
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

0 comments on commit dd433cb

Please sign in to comment.