Skip to content

Feat/add basic arrays #181

Feat/add basic arrays

Feat/add basic arrays #181

Workflow file for this run

# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0
name: CI/CD
on:
push:
branches:
- main # run pipeline on pull request
pull_request:
workflow_dispatch: # run this workflow manually from the Actions tab
inputs:
create_release:
type: boolean
description: Create a release (only works on main branch)
default: false
required: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-ci-build
cancel-in-progress: true
jobs:
ci-started:
runs-on: ubuntu-latest
steps:
- run: echo "ci started"
build-python:
if: ${{ github.ref == 'refs/heads/main' && inputs.create_release }}
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout source code
uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
if: ${{ always() }}
with:
activate-environment: true
enable-cache: true
- name: Install dependencies
if: ${{ always() }}
run: uv sync --frozen
- name: Set PyPI version
uses: PowerGridModel/pgm-version-bump@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Save version
id: version
run: echo "version=$(cat PYPI_VERSION)" >> $GITHUB_OUTPUT
- name: Build
run: |
uv build
- name: Store built wheel file
uses: actions/upload-artifact@v5
with:
name: power-grid-model-ds
path: dist/
tests:
if: ${{ github.ref == 'refs/heads/main' && inputs.create_release }}
needs: build-python
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python: ["3.11", "3.12", "3.13"]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
if: ${{ always() }}
with:
activate-environment: true
enable-cache: true
- name: install poe
run: uv tool install poethepoet
- name: Load built wheel file
uses: actions/download-artifact@v6
with:
name: power-grid-model-ds
path: dist/
- name: Install built wheel file
run: uv pip install power-grid-model-ds[dev]==${{ needs.build-python.outputs.version }} --find-links=dist
- name: Run All Code Quality Checks & Tests
run: poe all --check
github-release:
if: ${{ github.ref == 'refs/heads/main' && inputs.create_release }}
needs:
- build-python
- tests
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- name: Checkout source code
uses: actions/checkout@v5
- name: Load built wheel file
uses: actions/download-artifact@v6
with:
name: power-grid-model-ds
path: dist/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get tag
id: tag
run: echo "tag=v${{ needs.build-python.outputs.version }}" >> $GITHUB_OUTPUT
- name: Display tag
run: echo "${{ steps.tag.outputs.tag }}"
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
./dist/*
tag_name: ${{ steps.tag.outputs.tag }}
generate_release_notes: true
target_commitish: ${{ github.sha }}
publish:
name: Publish to PyPI
if: ${{ github.ref == 'refs/heads/main' && inputs.create_release }}
needs: github-release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # Required for Trusted Publishing
steps:
- name: Download assets from latest GitHub release using gh CLI
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p assets-to-publish
release_tag="${{ needs.github-release.outputs.tag }}"
gh release download "$release_tag" --repo "$GITHUB_REPOSITORY" --dir assets-to-publish
- name: List downloaded assets
run: ls -la assets-to-publish
- name: Upload assets to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
# To test, use the TestPyPI:
# repository-url: https://test.pypi.org/legacy/
# You must also create an account and project on TestPyPI,
# as well as set the trusted-publisher in the project settings:
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
# To publish to the official PyPI repository, just keep
# repository-url commented out.
packages-dir: assets-to-publish
skip-existing: true
print-hash: true
verbose: true
check-code-quality:
uses: "./.github/workflows/check-code-quality.yml"
reuse-compliance:
uses: "./.github/workflows/reuse-compliance.yml"