mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-20 23:38:42 +01:00
update Release notes template manually
This commit is contained in:
10
.github/workflows/build_documentation.yml
vendored
10
.github/workflows/build_documentation.yml
vendored
@@ -78,12 +78,6 @@ jobs:
|
||||
python docs/main_index/render_main_index.py \
|
||||
--version "${{ steps.version.outputs.version }}" \
|
||||
--date "$(date +'%d.%m.%Y')"
|
||||
|
||||
# update paths to documentation version etc in release notes
|
||||
- name: Update Release Notes
|
||||
if: github.event_name == 'release'
|
||||
run: |
|
||||
python etc/generate_release_notes.py --version "${{ steps.version.outputs.version }}"
|
||||
|
||||
- name: Checkout gh-pages
|
||||
uses: actions/checkout@v4
|
||||
@@ -98,8 +92,8 @@ jobs:
|
||||
VERSION="${{ steps.version.outputs.version }}"
|
||||
mkdir -p "gh-pages/${VERSION}"
|
||||
cp -r build/docs/html/. "gh-pages/${VERSION}/"
|
||||
cp docs/main_index/index.html "gh-pages/index.html"
|
||||
cp docs/main_index/index.html "gh-pages/_sources/index.html.txt"
|
||||
cp docs/main_index/index.html gh-pages/index.html
|
||||
cp docs/main_index/index.html gh-pages/_sources/index.html.txt
|
||||
if [ "${{ github.event_name }}" == "release" ]; then
|
||||
cp RELEASE.md "gh-pages/releases/RELEASE_v${VERSION}.md"
|
||||
fi
|
||||
|
||||
@@ -45,11 +45,11 @@ added patternstart to python (ctb, xilinx_ctb , mythen3), only the detector clas
|
||||
==========================================
|
||||
|
||||
|
||||
Eiger {{VERSION}}
|
||||
Jungfrau {{VERSION}}
|
||||
Mythen3 {{VERSION}}
|
||||
Gotthard2 {{VERSION}}
|
||||
Moench {{VERSION}}
|
||||
Eiger 10.0.0
|
||||
Jungfrau 10.0.0
|
||||
Mythen3 10.0.0
|
||||
Gotthard2 10.0.0
|
||||
Moench 10.0.0
|
||||
|
||||
|
||||
On-board Detector Server Upgrade
|
||||
@@ -6,19 +6,18 @@ Script to update VERSION file with semantic versioning if provided as an argumen
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from tempfile import template
|
||||
import yaml
|
||||
import argparse
|
||||
|
||||
from packaging.version import Version, InvalidVersion
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
def get_version():
|
||||
|
||||
# Check at least one argument is passed
|
||||
if len(sys.argv) < 2:
|
||||
return "0.0.0"
|
||||
|
||||
version = sys.argv[1]
|
||||
def get_version(version : str) -> str:
|
||||
|
||||
try:
|
||||
v = Version(version) # normalizcheck if version follows PEP 440 specification
|
||||
@@ -35,8 +34,57 @@ def write_version_to_file(version):
|
||||
version_file.write(version)
|
||||
print(f"Version {version} written to VERSION file.")
|
||||
|
||||
|
||||
def extract_release_type(version: str) -> str:
|
||||
"""Extract release type from version string."""
|
||||
parts = version.split('.')
|
||||
if len(parts) != 3:
|
||||
raise ValueError(f"Version {version} does not follow semantic versioning format of major.minor.patch")
|
||||
major, minor, patch = map(int, parts)
|
||||
if minor == 0 and patch == 0:
|
||||
return "Major"
|
||||
elif patch == 0:
|
||||
return "Minor"
|
||||
else:
|
||||
return "Bug Fix"
|
||||
|
||||
def get_previous_version(data_path: Path, version : str) -> str:
|
||||
"""Get the previous version from the versions YAML file."""
|
||||
with open(data_path, 'r') as f:
|
||||
data = yaml.safe_load(f)
|
||||
|
||||
prev_version = data['versions'][0]["version"]
|
||||
if prev_version == version: #already updated to new version
|
||||
prev_version = data['versions'][1]["version"]
|
||||
|
||||
return prev_version
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Update version release notes')
|
||||
parser.add_argument('--version', required=True, type=str, help='version to write to VERSION file')
|
||||
parser.add_argument('--update_version_only', action="store_true", help='Only update version in VERSION file, do not generate release notes')
|
||||
args = parser.parse_args()
|
||||
|
||||
version = get_version(args.version)
|
||||
write_version_to_file(version)
|
||||
|
||||
if not args.update_version_only:
|
||||
release_type = extract_release_type(version)
|
||||
prev_version = get_previous_version(ROOT_DIR / "docs/main_index/versions.yaml", version)
|
||||
|
||||
# Read template
|
||||
template = Path(ROOT_DIR / "RELEASE.md").read_text()
|
||||
|
||||
# Substitute version and date
|
||||
output = template.replace("{{VERSION}}", version)
|
||||
output = output.replace("{{DATE}}", datetime.now().strftime("%Y-%m-%d"))
|
||||
output = output.replace("{{RELEASE_TYPE}}", release_type)
|
||||
output = output.replace("{{PREVIOUS_VERSION}}", prev_version)
|
||||
|
||||
# Write output
|
||||
Path(ROOT_DIR / "RELEASE.md").write_text(output)
|
||||
print(f"Generated RELEASE.md for version {version}")
|
||||
|
||||
# Main script
|
||||
if __name__ == "__main__":
|
||||
|
||||
version = get_version()
|
||||
write_version_to_file(version)
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user