Skip to content

Build Package

Build Package #3

---
name: Build Package
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Cache pipenv dependencies
uses: actions/cache@v3
with:
path: |
~/.local/share/virtualenvs
~/.cache/pipenv
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-pipenv-
- name: Install pipenv
run: |
python -m pip install pipenv
- name: Install dependencies
run: |
PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy --ignore-pipfile --dev
- name: Run tests
run: pipenv run python -m pytest
- name: Build
run: pipenv run python -m build
- name: Archive package artifacts
uses: actions/upload-artifact@v3
with:
name: python-package
path: dist/*
publish:
runs-on: ubuntu-latest
environment:
name: publish-approval
steps:
- name: Download pacakge artifacts
uses: actions/download-artifact@v3
with:
name: python-package
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install twine
run: |
python -m pip install --upgrade pip
python -m pip install twine
- name: Publish
run: twine upload dist/*