2022-08-03 18:57:27 +00:00
|
|
|
name: publish
|
|
|
|
|
|
|
|
on:
|
2022-08-15 03:47:36 +00:00
|
|
|
push:
|
|
|
|
tags:
|
2023-01-04 23:46:48 +00:00
|
|
|
- "*"
|
2022-08-03 18:57:27 +00:00
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
paths:
|
2022-08-04 00:49:32 +00:00
|
|
|
- src/**
|
|
|
|
- setup.py
|
|
|
|
- .github/workflows/publish.yml
|
2022-08-15 03:47:36 +00:00
|
|
|
pull_request:
|
2022-08-04 00:49:32 +00:00
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
paths:
|
|
|
|
- src/**
|
2022-08-03 18:57:27 +00:00
|
|
|
- setup.py
|
|
|
|
- .github/workflows/publish.yml
|
|
|
|
|
|
|
|
jobs:
|
2022-08-04 00:49:32 +00:00
|
|
|
publish:
|
2022-08-03 18:57:27 +00:00
|
|
|
name: Publish App to PyPI
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Set up Python 3.10
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: '3.10'
|
|
|
|
|
2022-08-03 19:37:16 +00:00
|
|
|
- name: Install Dependencies
|
2022-08-03 18:57:27 +00:00
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
2022-08-03 19:01:18 +00:00
|
|
|
pip install build twine
|
2022-08-03 19:37:16 +00:00
|
|
|
|
|
|
|
- name: Install Application
|
|
|
|
run: |
|
2022-08-03 18:57:27 +00:00
|
|
|
pip install --upgrade .
|
|
|
|
|
2022-08-04 01:40:35 +00:00
|
|
|
- name: Publish Release to PyPI
|
2022-08-15 03:47:36 +00:00
|
|
|
if: startsWith(github.ref, 'refs/tags')
|
2022-08-04 01:40:35 +00:00
|
|
|
env:
|
|
|
|
TWINE_USERNAME: __token__
|
|
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }}
|
2022-08-03 18:57:27 +00:00
|
|
|
run: |
|
2022-08-17 16:53:44 +00:00
|
|
|
# Setup Environment for Reproducible Builds
|
|
|
|
export PYTHONHASHSEED=42
|
2022-08-19 18:00:12 +00:00
|
|
|
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
2022-08-17 16:53:44 +00:00
|
|
|
|
2022-08-19 18:00:12 +00:00
|
|
|
# Build and Upload PyPi Package
|
2022-08-03 18:57:27 +00:00
|
|
|
rm -rf dist
|
|
|
|
python -m build
|
2022-08-03 19:37:16 +00:00
|
|
|
twine check dist/*
|
2023-01-05 15:56:46 +00:00
|
|
|
twine upload --verbose dist/*
|
2022-08-03 18:57:27 +00:00
|
|
|
|
2022-08-04 01:40:35 +00:00
|
|
|
- name: Publish Master to PyPI
|
|
|
|
if: github.ref == 'refs/heads/master'
|
2022-08-04 00:18:51 +00:00
|
|
|
env:
|
|
|
|
TWINE_USERNAME: __token__
|
|
|
|
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }}
|
|
|
|
run: |
|
2022-08-19 18:00:12 +00:00
|
|
|
# Set Pre-Release Version
|
2022-08-04 01:40:35 +00:00
|
|
|
sed -E -i "s/version=(.*)',/version=\1a$(date +%s)',/g" setup.py
|
2022-08-19 18:00:12 +00:00
|
|
|
|
|
|
|
# Setup Environment for Reproducible Builds
|
|
|
|
export PYTHONHASHSEED=42
|
|
|
|
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
|
|
|
|
|
|
|
# Build and Upload PyPi Package
|
2022-08-04 01:40:35 +00:00
|
|
|
rm -rf dist
|
|
|
|
python -m build
|
|
|
|
twine check dist/*
|
2023-01-05 15:56:46 +00:00
|
|
|
twine upload --verbose dist/*
|
2022-08-04 00:18:51 +00:00
|
|
|
|
2022-08-04 00:49:32 +00:00
|
|
|
- name: Publish PR to Test PyPI
|
|
|
|
if: github.event_name == 'pull_request'
|
|
|
|
env:
|
|
|
|
TWINE_USERNAME: __token__
|
|
|
|
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_KEY }}
|
|
|
|
PULL_REQUEST_NUMBER: ${{ github.event.number }}
|
|
|
|
run: |
|
2022-08-19 18:00:12 +00:00
|
|
|
# Set Development Release Version
|
2022-08-04 01:15:16 +00:00
|
|
|
sed -E -i "s/version=(.*)',/version=\1.dev$PULL_REQUEST_NUMBER$(date +%s)',/g" setup.py
|
2022-08-19 18:00:12 +00:00
|
|
|
|
|
|
|
# Setup Environment for Reproducible Builds
|
|
|
|
export PYTHONHASHSEED=42
|
|
|
|
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
|
|
|
|
|
|
|
|
# Build and Upload PyPi Package
|
2022-08-04 00:49:32 +00:00
|
|
|
rm -rf dist
|
|
|
|
python -m build
|
|
|
|
twine check dist/*
|
2023-01-05 15:56:46 +00:00
|
|
|
twine upload -r testpypi --verbose dist/*
|