Skip to content

Commit 007c8b0

Browse files
committed
chore: dev release
Signed-off-by: Alfred Razol <alfred.razol@rte-france.com>
1 parent 495203f commit 007c8b0

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.github/workflows/dev-release.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Dev Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "dev[0-9]+.[0-9]+.[0-9]+*"
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: astral-sh/setup-uv@v3
17+
18+
- name: Cache uv
19+
uses: actions/cache@v4
20+
with:
21+
path: ~/.cache/uv
22+
key: ${{ runner.os }}-uv-${{ hashFiles('**/uv.lock') }}
23+
24+
- run: uv sync --all-extras
25+
- run: uv run ruff check .
26+
- run: uv run ruff format --check .
27+
28+
dev-release:
29+
runs-on: ubuntu-22.04
30+
needs: lint
31+
32+
environment:
33+
name: pypi
34+
url: https://pypi.org/p/pypowsybl2grid
35+
36+
permissions:
37+
id-token: write
38+
39+
steps:
40+
- name: Install Ubuntu packages
41+
env:
42+
DEBIAN_FRONTEND: noninteractive
43+
run: |
44+
sudo apt update
45+
sudo apt -y install maven
46+
47+
- name: Checkout sources
48+
uses: actions/checkout@v4
49+
50+
- name: Install UV
51+
uses: astral-sh/setup-uv@v3
52+
53+
- name: Cache uv
54+
uses: actions/cache@v4
55+
with:
56+
path: ~/.cache/uv
57+
key: ${{ runner.os }}-uv-${{ hashFiles('**/uv.lock') }}
58+
59+
- name: Install dependencies
60+
run: uv sync --all-extras
61+
62+
- name: Set dev version
63+
run: |
64+
python3 << 'EOF'
65+
import re, os
66+
tag = os.environ['GITHUB_REF_NAME'] # e.g. dev0.3.1
67+
version = tag.removeprefix('dev') # e.g. 0.3.1
68+
dev_ver = f"{version}.dev{os.environ['GITHUB_RUN_NUMBER']}"
69+
with open('pyproject.toml', 'r') as f:
70+
content = f.read()
71+
content = re.sub(r'(?m)^version = ".*"', f'version = "{dev_ver}"', content)
72+
with open('pyproject.toml', 'w') as f:
73+
f.write(content)
74+
print(f"Version set to: {dev_ver}")
75+
EOF
76+
77+
- name: Run tests
78+
run: uv run pytest
79+
80+
- name: Build wheel
81+
run: uv build
82+
83+
- name: Publish on PyPi
84+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)