-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (142 loc) · 5.79 KB
/
release.yml
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
name: release
on:
workflow_dispatch:
milestone:
types: [closed]
jobs:
tests:
uses: ./.github/workflows/tests.yml
release:
name: Release a new version
runs-on: ubuntu-latest
needs: [tests]
env:
PYTHON_VERSION: "3.11"
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ secrets.ACCESS_TOKEN }}
fetch-depth: 0
- name: Temporarily disable 'include administrators' default branch protection
uses: benjefferies/branch-protection-bot@v1.1.2
if: always()
with:
access_token: ${{ secrets.ACCESS_TOKEN }}
branch: ${{ github.event.repository.default_branch }}
enforce_admins: false
- name: Update license year
uses: FantasticFiasco/action-update-license-year@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Merge license year pull request
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: gh pr merge --squash --delete-branch --admin
- name: Find new version
id: cz
uses: commitizen-tools/commitizen-action@0.20.0
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
push: false
commit: false
changelog: false
- name: Check out repository
uses: actions/checkout@v4
with:
token: ${{ secrets.ACCESS_TOKEN }}
fetch-depth: 0
- name: Set up PDM @ ${{ matrix.python-version }}
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: true
architecture: x64
- name: Install dependencies
run: pdm install
- name: Install graphviz
run: sudo apt-get install -y graphviz graphviz-dev
- name: Install erdantic
run: pdm add erdantic
- name: Generate schema diagram files
run: |
pdm run python -c 'import erdantic as erd
from psdm.steadystate_case.case import Case as SteadystateCase
from psdm.topology.topology import Topology
from psdm.topology_case.case import Case as TopologyCase
from pathlib import Path
f_top = Path(f"./schema/${{ steps.cz.outputs.version }}/topology.png")
f_top.parent.mkdir(exist_ok=True, parents=True)
erd.create(Topology).draw(f_top)
f_topc = Path(f"./schema/${{ steps.cz.outputs.version }}/topology_case.png")
f_topc.parent.mkdir(exist_ok=True, parents=True)
erd.create(TopologyCase).draw(f_topc)
f_ssc = Path(f"./schema/${{ steps.cz.outputs.version }}/steady_state_case.png")
f_ssc.parent.mkdir(exist_ok=True, parents=True)
erd.create(SteadystateCase).draw(f_ssc)'
- name: Copy diagrams to docs
run: yes | cp -rf ./schema/${{ steps.cz.outputs.version }}/*.png ./docs/
- name: Stage schema diagram files
run: git add ./docs
- name: Generate schema JSON files
run: |
pdm run python -c 'from psdm.steadystate_case.case import Case as SteadystateCase
from psdm.topology.topology import Topology
from psdm.topology_case.case import Case as TopologyCase
from pathlib import Path
import json
f_top = Path(f"./schema/${{ steps.cz.outputs.version }}/topology.json")
f_top.parent.mkdir(exist_ok=True, parents=True)
with f_top.open(mode="w") as f:
json.dump(Topology.model_json_schema(), f, indent=2)
f_topc = Path(f"./schema/${{ steps.cz.outputs.version }}/topology_case.json")
f_topc.parent.mkdir(exist_ok=True, parents=True)
with f_topc.open(mode="w") as f:
json.dump(TopologyCase.model_json_schema(), f, indent=2)
f_ssc = Path(f"./schema/${{ steps.cz.outputs.version }}/steady_state_case.json")
f_ssc.parent.mkdir(exist_ok=True, parents=True)
with f_ssc.open(mode="w") as f:
json.dump(SteadystateCase.model_json_schema(), f, indent=2)'
- name: Stage schema JSON files
run: git add ./schema
- name: Delete unstages changes
run: git restore .
- name: Get current date
id: get_date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Update .zenodo.json date
run: echo "`jq '.publication_date="${{ steps.get_date.outputs.date }}"' .zenodo.json`" > .zenodo.json
- name: Update .zenodo.json url
run: echo "`jq '.related_identifiers[0].identifier="https://github.com/ieeh-tu-dresden/power-system-data-model/tree/${{ steps.cz.outputs.version }}"' .zenodo.json`" > .zenodo.json
- name: Bump version and create changelog
uses: commitizen-tools/commitizen-action@0.20.0
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
changelog_increment_filename: body.md
- name: Restore 'include administrators' default branch protection
uses: benjefferies/branch-protection-bot@v1.1.2
if: always()
with:
access_token: ${{ secrets.ACCESS_TOKEN }}
branch: ${{ github.event.repository.default_branch }}
enforce_admins: ${{ steps.disable_include_admins.outputs.initial_status }}
- name: Build Python packages
run: pdm build
- name: Publish Python packages
run: pdm publish
env:
PDM_PUBLISH_REPO: pypi
PDM_PUBLISH_USERNAME: __token__
PDM_PUBLISH_PASSWORD: ${{ secrets.PYPI_TOKEN }}
- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: body.md
tag_name: ${{ env.REVISION }}
files: |
dist/*.whl
dist/*.tar.gz
LICENSE
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}