Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 0 additions & 186 deletions .github/workflows/build-test-release.yml

This file was deleted.

149 changes: 143 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,152 @@ jobs:
steps:
- run: echo "ci started"

build-test-release:
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
name: build-test-release
uses: "./.github/workflows/build-test-release.yml"
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@v6
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@v4
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@v6
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@v4
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@v4
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
with:
create_release: ${{ inputs.create_release }}
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"
Expand Down
Loading