Skip to content

Build

Build #105

Workflow file for this run

# Runs a build test on commit to ensure functionality.
name: Build
on:
push:
tags:
- "*.*.*"
workflow_run:
workflows: ["Type Coverage and Linting"]
types: [completed]
branches: [main]
jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' || startsWith(github.ref, 'refs/tags') }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.x"]
name: "Build @ ${{ matrix.python-version }}"
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Setup PDM @ ${{ matrix.python-version }}"
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{matrix.python-version}}
cache: true
- name: "Install deps @ ${{ matrix.python-version }}"
run: |
pdm install --prod --check --no-editable
- name: "Activate venv @ ${{ matrix.python-version }}"
run: |
echo "$(pdm info --where)/.venv/bin" >> $GITHUB_PATH
- name: "Check it imports @ ${{ matrix.python-version }}"
run: |
pdm run python -c 'import mystbin'
- name: "Build wheels @ ${{ matrix.python-version}}"
run: |
pdm build
- name: "Build docs @ ${{ matrix.python-version}}"
working-directory: docs/
run: |
pdm run docs
- name: "Upload artifacts @ ${{ matrix.python-version}}"
if: ${{ matrix.python-version != '3.x' }}
uses: actions/upload-artifact@v4
with:
name: distributions
path: dist/*
# Credits to most of this step go to Gorialis (Devon R [https://github.com/Gorialis])
# as I found them in their Jishaku builds (https://github.com/Gorialis/jishaku/blob/d3f50749b5a977b544e5fd14894585f656247486/.github/workflows/deploy.yml#L82-L119)
create_release:
name: Create Release
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: distributions
path: dist
- name: Create GitHub release
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in ./dist/*.{whl,tar.gz}; do
assets+=("$asset")
done
tag_name="${GITHUB_REF##*/}"
gh release create "$tag_name" -F "CHANGELOG.md" "${assets[@]}"
- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: 3.8
cache: true
- name: Publish to PyPI
run: |
pdm publish