From a6a473f9baefd3a21e7566297337a5be63d50528 Mon Sep 17 00:00:00 2001 From: IhsenBouallegue Date: Thu, 12 Dec 2024 14:11:23 +0100 Subject: [PATCH] refactor(config): update release workflows to trigger on all release markdown files --- .github/workflows/release-analysis.yml | 2 +- .github/workflows/release-visualization.yml | 2 +- script/version-manager.ts | 37 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-analysis.yml b/.github/workflows/release-analysis.yml index 11c636e9cd..cd1c0d76e5 100644 --- a/.github/workflows/release-analysis.yml +++ b/.github/workflows/release-analysis.yml @@ -8,7 +8,7 @@ on: - main paths: - 'analysis/**' - - 'gh-pages/_posts/release/*ana_*.md' + - 'gh-pages/_posts/release/**' env: VERSION: "0.0.0" diff --git a/.github/workflows/release-visualization.yml b/.github/workflows/release-visualization.yml index 4143486529..2587e6afcb 100644 --- a/.github/workflows/release-visualization.yml +++ b/.github/workflows/release-visualization.yml @@ -8,7 +8,7 @@ on: - main paths: - 'visualization/**' - - 'gh-pages/_posts/release/*vis_*.md' + - 'gh-pages/_posts/release/**' env: VERSION: "0.0.0" diff --git a/script/version-manager.ts b/script/version-manager.ts index be086d258f..6a2dd88e0e 100644 --- a/script/version-manager.ts +++ b/script/version-manager.ts @@ -55,6 +55,36 @@ class VersionManager { } } + private updateReadme(repository: Repository, newVersion: string): void { + const readmePath = "README.md" + const readme = fs.readFileSync(readmePath, "utf8") + + // Find the line with version links + const versionLineRegex = /Analysis (.*?)<\/a> \| Visualization (.*?)<\/a>/ + const match = readme.match(versionLineRegex) + + if (!match) { + throw new Error("Could not find version line in README.md") + } + + let updatedReadme = readme + const prefix = repository === "visualization" ? "vis" : "ana" + + if (repository === "visualization") { + updatedReadme = readme.replace( + versionLineRegex, + `Analysis ${match[1]} | Visualization ${newVersion}` + ) + } else { + updatedReadme = readme.replace( + versionLineRegex, + `Analysis ${newVersion} | Visualization ${match[2]}` + ) + } + + fs.writeFileSync(readmePath, updatedReadme) + } + public updateVersion(repository: string, type: string): string { try { // Validate inputs @@ -76,6 +106,13 @@ class VersionManager { throw new Error(`Failed to update version in ${normalizedRepo}/package.json: ${error}`) } + // 2. Update README.md + try { + this.updateReadme(normalizedRepo, newVersion) + } catch (error) { + throw new Error(`Failed to update README.md: ${error}`) + } + // 2. If analysis, also update gradle.properties if (normalizedRepo === "analysis") { try {