Skip to content

Commit

Permalink
🚸 Special case version 4.8.5 (#331)
Browse files Browse the repository at this point in the history
This makes the action work for Z3 4.8.5 which was tagged differently and
has an uppercase Z in the tag name.

---------

Signed-off-by: burgholzer <[email protected]>
Co-authored-by: burgholzer <[email protected]>
  • Loading branch information
mtzguido and burgholzer authored Oct 11, 2024
1 parent 2c39de9 commit 2899695
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe("Z3 Setup Tests", () => {
{ name: "windows_latest", version: "latest", platform: "windows", addToLibraryPath: "true" },
{ name: "specific_version", version: "4.8.17" },
{ name: "old_version_macOS", version: "4.8.11", platform: "macOS", addToLibraryPath: "true" },
{ name: "old_version_linux", version: "4.8.10", platform: "linux", addToLibraryPath: "true" }
{ name: "old_version_linux", version: "4.8.10", platform: "linux", addToLibraryPath: "true" },
{ name: "special_case_4.8.5", version: "4.8.5", platform: "linux" }
]

for (const { name, version, platform, architecture, addToLibraryPath } of testCases) {
Expand Down
13 changes: 7 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/get-download-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ async function getRelease(token: string, version: string): Promise<{ assets: Rel
})
return { assets: response.data.assets, version: response.data.tag_name }
} else {
const response = await octokit.request("GET /repos/{owner}/{repo}/releases/tags/z3-{tag}", {
// Unlike all other tags, 4.8.5 has an uppercase Z
const tag = (version == "4.8.5") ? "Z3-4.8.5" : `z3-${version}`;
const response = await octokit.request("GET /repos/{owner}/{repo}/releases/tags/{tag}", {
owner: "Z3Prover",
repo: "z3",
tag: version
tag: tag
})
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
return { assets: response.data.assets, version: response.data.tag_name }
}
}
Expand All @@ -112,15 +113,15 @@ function findAsset(
architecture: string
): ReleaseAsset | undefined {
if (platform === "linux") {
return assets.find(asset => RegExp(new RegExp(`^${version}-${architecture}-(ubuntu|glibc)-.*$`)).exec(asset.name))
return assets.find(asset => RegExp(`^${version}-${architecture}-(ubuntu|glibc)-.*$`, 'i').exec(asset.name))
}

if (platform === "macOS") {
return assets.find(asset => RegExp(new RegExp(`^${version}-${architecture}-osx-.*$`)).exec(asset.name))
return assets.find(asset => RegExp(`^${version}-${architecture}-osx-.*$`, 'i').exec(asset.name))
}

if (platform === "windows") {
return assets.find(asset => RegExp(new RegExp(`^${version}-${architecture}-win.*$`)).exec(asset.name))
return assets.find(asset => RegExp(`^${version}-${architecture}-win.*$`, 'i').exec(asset.name))
}

throw new Error(`Invalid platform: ${platform}`)
Expand Down

0 comments on commit 2899695

Please sign in to comment.