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