-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (120 loc) · 4.57 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
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@v3
with:
token: ${{ secrets.ACCESS_TOKEN }}
fetch-depth: 0
- name: Temporarily disable 'include administrators' default branch protection
uses: benjefferies/branch-protection-bot@1.0.9
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.18.2
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
push: false
commit: false
changelog: false
- name: Check out repository
uses: actions/checkout@v3
with:
token: ${{ secrets.ACCESS_TOKEN }}
fetch-depth: 0
- name: Set up PDM @ ${{ matrix.python-version }}
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: true
architecture: x64
enable-pep582: true
env:
PDM_DEPS: "urllib3<2"
- name: Installing dependencies
run: pdm install
- name: Generate schema JSON files
run: pdm run python -c '$COMMAND'
env:
COMMAND: |
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.json")
f_top.parent.mkdir(exist_ok=True, parents=True)
with open(f_top, "w") as f:
f.write(Topology.schema_json(indent=2))
f_topc = Path(f"./schema/${{ steps.cz.outputs.version }}/topology_case.json")
f_topc.parent.mkdir(exist_ok=True, parents=True)
with open(f_topc, "w") as f:
f.write(TopologyCase.schema_json(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 open(f_ssc, "w") as f:
f.write(SteadystateCase.schema_json(indent=2))
- name: Stage schema JSON files
run: git add ./schema
- 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@master
with:
github_token: ${{ secrets.ACCESS_TOKEN }}
changelog_increment_filename: body.md
- name: Restore 'include administrators' default branch protection
uses: benjefferies/branch-protection-bot@master
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 }}