Skip to content

build: update build config #4

build: update build config

build: update build config #4

Workflow file for this run

name: CI
on:
push:
branches:
- main
- alpha
- beta
pull_request:
branches:
- main
- alpha
- beta
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# Should run on every push and PR
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Install hatch
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Test
run: hatch run tests:run
# Should run on every push and PR, but only run semantic-release on push
release:
name: Run semantic-release
runs-on: ubuntu-latest
needs: test
permissions:
contents: write
issues: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Semantic Release
uses: docker://ghcr.io/codfish/semantic-release-action@sha256:9e0bbcc4ca3b3611668dcf911e51432573efb3222587c4ca1cc8a759c1b8283c # v3.1.1
# Only run on push events
if: github.event_name == 'push'
id: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# TODO: Set to false to actually publish
dry-run: true
plugins: |
[
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
]
outputs:
version: ${{ steps.semantic-release.outputs.release-version || '0.0.0-dev' }}
# TODO: Set to true to actually publish
# published: ${{ steps.semantic-release.outputs.new-release-published || 'false' }}
published: 'false'
# Should run on every push and PR
build-wheel:
name: Build wheel for ${{ matrix.os }}-${{ matrix.arch }}
needs: release
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
arch: [x64, arm64]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Write version to file
run: echo ${{ needs.release.outputs.version }} > VERSION.txt
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install build
run: |
python -m pip install --upgrade pip
pip install --upgrade build
- name: Build wheel
run: python -m build --wheel
env:
BUILD_TARGET_ARCH: ${{ matrix.arch }}
- name: Repair macOS wheel
if: startsWith(matrix.os, 'macos')
run: |
pip install delocate
delocate-wheel -v dist/*.whl
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-${{ matrix.arch }}
path: dist/*.whl
# Should run on every push and PR
build-wheel-linux:
name: Build wheel for manylinux-x64
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Write version to file
run: echo ${{ needs.release.outputs.version }} > VERSION.txt
- name: Build wheels
uses: pypa/cibuildwheel@v2.17
env:
CIBW_BUILD: "*-manylinux_x86_64"
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_28_x86_64
CIBW_BEFORE_ALL_LINUX: dnf install -y dotnet-sdk-8.0
CIBW_BUILD_FRONTEND: build
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-manylinux
path: wheelhouse/*.whl
# Should run on every push and PR
sdist:
name: Build sdist
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Write version to file
run: echo ${{ needs.release.outputs.version }} > VERSION.txt
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install build
run: |
python -m pip install --upgrade pip
pip install --upgrade build
- name: Build sdist
run: python -m build --sdist
- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
# For branch protection rules
check:
if: always()
needs:
- build-wheel
- build-wheel-linux
- sdist
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
# Should run only on push
publish:
name: Publish to PyPI
needs:
- build-wheel
- build-wheel-linux
- sdist
- release
if: needs.release.outputs.published == 'true' && github.event_name == 'push'
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# TODO: Switch to pypi when ready
repository-url: https://test.pypi.org/legacy/