xch-blockchain/.github/workflows/upload-pypi-source.yml

209 lines
5.6 KiB
YAML

name: 🚨🚀 Lint and upload source distribution
on:
push:
paths-ignore:
- '**.md'
branches:
- 'long_lived/**'
- main
- 'release/**'
release:
types: [published]
pull_request:
paths-ignore:
- '**.md'
branches:
- '**'
concurrency:
# SHA is added to the end if on `main` to let all main workflows run
group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }}
cancel-in-progress: true
jobs:
mypy:
name: ${{ matrix.os.emoji }} ${{ matrix.check.name }} - ${{ matrix.os.name }} ${{ matrix.arch.name }} ${{ matrix.python.major_dot_minor }}
runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os:
- name: Linux
matrix: linux
emoji: 🐧
runs-on:
intel: ubuntu-latest
arm: [linux, arm64]
- name: macOS
matrix: macos
emoji: 🍎
runs-on:
intel: macos-latest
arm: [macos, arm64]
- name: Windows
matrix: windows
emoji: 🪟
runs-on:
intel: windows-latest
arch:
- name: ARM64
matrix: arm
- name: Intel
matrix: intel
python:
- major_dot_minor: '3.7'
- major_dot_minor: '3.8'
- major_dot_minor: '3.9'
- major_dot_minor: '3.10'
- major_dot_minor: '3.11'
check:
- name: mypy
command: |
echo "MYPY VERSION IS: $(mypy --version)"
python manage-mypy.py build-mypy-ini
mypy
exclude:
- os:
matrix: macos
python:
major_dot_minor: '3.7'
- os:
matrix: macos
arch:
matrix: arm
python:
major_dot_minor: '3.8'
- os:
matrix: windows
arch:
matrix: arm
steps:
- uses: chia-network/actions/clean-workspace@main
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: chia-network/actions/setup-python@main
with:
python-version: ${{ matrix.python.major_dot_minor }}
- uses: ./.github/actions/install
with:
python-version: ${{ matrix.python.major_dot_minor }}
development: true
- uses: chia-network/actions/activate-venv@main
- name: Check with ${{ matrix.check.name }}
run: |
${{ matrix.check.command }}
check:
name: ${{ matrix.os.emoji }} ${{ matrix.check.name }} - ${{ matrix.os.name }} ${{ matrix.arch.name }} ${{ matrix.python.major_dot_minor }}
runs-on: ${{ matrix.os.runs-on[matrix.arch.matrix] }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
os:
- name: Linux
matrix: linux
emoji: 🐧
runs-on:
intel: ubuntu-latest
arm: [linux, arm64]
arch:
- name: Intel
matrix: intel
python:
- major_dot_minor: '3.8'
check:
- name: black
command: black --check --diff .
- name: flake8
command: flake8 benchmarks build_scripts chia tests tools *.py
- name: pylint
command: pylint benchmarks build_scripts chia tests tools *.py
steps:
- uses: chia-network/actions/clean-workspace@main
- uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: chia-network/actions/setup-python@main
with:
python-version: ${{ matrix.python.major_dot_minor }}
- uses: ./.github/actions/install
with:
python-version: ${{ matrix.python.major_dot_minor }}
development: true
- uses: chia-network/actions/activate-venv@main
- name: Check with ${{ matrix.check.name }}
run: |
${{ matrix.check.command }}
upload_source_dist:
name: Lint and Upload source distribution
runs-on: [ubuntu-latest]
timeout-minutes: 30
needs:
- mypy
- check
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
- uses: Chia-Network/actions/setup-python@main
name: Install Python
with:
python-version: '3.8'
- name: Test for secrets access
id: check_secrets
shell: bash
run: |
unset HAS_SECRET
if [ -n "$SECRET" ]; then HAS_SECRET='true' ; fi
echo HAS_SECRET=${HAS_SECRET} >> $GITHUB_OUTPUT
env:
SECRET: "${{ secrets.test_pypi_password }}"
- uses: ./.github/actions/install
with:
python-version: ${{ matrix.python.major_dot_minor }}
development: true
- uses: chia-network/actions/activate-venv@main
- name: Build source distribution
run: |
python -m build --sdist --outdir dist .
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist
- name: Publish distribution to PyPI
if: steps.check_secrets.outputs.HAS_SECRET && startsWith(github.ref, 'refs/tags')
env:
TWINE_USERNAME: __token__
TWINE_NON_INTERACTIVE: 1
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: twine upload --non-interactive --skip-existing --verbose 'dist/*'