release #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |