-
Notifications
You must be signed in to change notification settings - Fork 16
182 lines (154 loc) · 5.53 KB
/
Copy pathci.yml
File metadata and controls
182 lines (154 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
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@b75ff549cae00be1ca859d181dbc460f69003643 # v0.1.2
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@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
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.12", "3.13", "3.14"]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
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@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Load built wheel file
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
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@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
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@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
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"