Skip to content

Commit

Permalink
refactor(config): update release workflows to trigger on all release …
Browse files Browse the repository at this point in the history
…markdown files
  • Loading branch information
IhsenBouallegue committed Dec 12, 2024
1 parent 858cba1 commit a6a473f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- main
paths:
- 'analysis/**'
- 'gh-pages/_posts/release/*ana_*.md'
- 'gh-pages/_posts/release/**'

env:
VERSION: "0.0.0"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-visualization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- main
paths:
- 'visualization/**'
- 'gh-pages/_posts/release/*vis_*.md'
- 'gh-pages/_posts/release/**'

env:
VERSION: "0.0.0"
Expand Down
37 changes: 37 additions & 0 deletions script/version-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 href=".*?">(.*?)<\/a> \| Visualization <a href=".*?">(.*?)<\/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 <a href="https://github.com/MaibornWolff/codecharta/releases/tag/ana-${match[1]}">${match[1]}</a> | Visualization <a href="https://github.com/MaibornWolff/codecharta/releases/tag/vis-${newVersion}">${newVersion}</a>`
)
} else {
updatedReadme = readme.replace(
versionLineRegex,
`Analysis <a href="https://github.com/MaibornWolff/codecharta/releases/tag/ana-${newVersion}">${newVersion}</a> | Visualization <a href="https://github.com/MaibornWolff/codecharta/releases/tag/vis-${match[2]}">${match[2]}</a>`
)
}

fs.writeFileSync(readmePath, updatedReadme)
}

public updateVersion(repository: string, type: string): string {
try {
// Validate inputs
Expand All @@ -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 {
Expand Down

0 comments on commit a6a473f

Please sign in to comment.