Skip to content

Commit 2899695

Browse files
mtzguidoburgholzer
andauthored
🚸 Special case version 4.8.5 (#331)
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 <burgholzer@me.com> Co-authored-by: burgholzer <burgholzer@me.com>
1 parent 2c39de9 commit 2899695

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

__tests__/main.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ describe("Z3 Setup Tests", () => {
3636
{ name: "windows_latest", version: "latest", platform: "windows", addToLibraryPath: "true" },
3737
{ name: "specific_version", version: "4.8.17" },
3838
{ name: "old_version_macOS", version: "4.8.11", platform: "macOS", addToLibraryPath: "true" },
39-
{ name: "old_version_linux", version: "4.8.10", platform: "linux", addToLibraryPath: "true" }
39+
{ name: "old_version_linux", version: "4.8.10", platform: "linux", addToLibraryPath: "true" },
40+
{ name: "special_case_4.8.5", version: "4.8.5", platform: "linux" }
4041
]
4142

4243
for (const { name, version, platform, architecture, addToLibraryPath } of testCases) {

dist/index.js

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/get-download-link.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ async function getRelease(token: string, version: string): Promise<{ assets: Rel
8787
})
8888
return { assets: response.data.assets, version: response.data.tag_name }
8989
} else {
90-
const response = await octokit.request("GET /repos/{owner}/{repo}/releases/tags/z3-{tag}", {
90+
// Unlike all other tags, 4.8.5 has an uppercase Z
91+
const tag = (version == "4.8.5") ? "Z3-4.8.5" : `z3-${version}`;
92+
const response = await octokit.request("GET /repos/{owner}/{repo}/releases/tags/{tag}", {
9193
owner: "Z3Prover",
9294
repo: "z3",
93-
tag: version
95+
tag: tag
9496
})
95-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
9697
return { assets: response.data.assets, version: response.data.tag_name }
9798
}
9899
}
@@ -112,15 +113,15 @@ function findAsset(
112113
architecture: string
113114
): ReleaseAsset | undefined {
114115
if (platform === "linux") {
115-
return assets.find(asset => RegExp(new RegExp(`^${version}-${architecture}-(ubuntu|glibc)-.*$`)).exec(asset.name))
116+
return assets.find(asset => RegExp(`^${version}-${architecture}-(ubuntu|glibc)-.*$`, 'i').exec(asset.name))
116117
}
117118

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

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

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

0 commit comments

Comments
 (0)