Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/PORTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,15 @@ cd installer && cargo xwin build --release --target x86_64-pc-windows-msvc -p ii
tools/deploy-ii.sh && tools/release.sh # -> dist/release/ii-windows-<VERSION>.zip, .sha256, ii-windows-setup.exe
```
`VERSION` (repo root) is the release version; `installer/Cargo.toml` must say the same
(`release.sh` checks). The zip is `dist/ii-windows` minus `testconfigs`, plus `VERSION` and the
setup exe itself (an update installs the matching setup into the install dir).
(`release.sh` checks). A tag build rejects a `VERSION` older than its tag, while allowing the same
version or a newer hotfix such as `-fix1`. The zip is `dist/ii-windows` minus `testconfigs`, plus
`VERSION` and the setup exe itself (an update installs the matching setup into the install dir).

At run time the package comes from the latest release of `nunreasonable/ii-windows` (assets
`ii-windows-<version>.zip` + `.zip.sha256`), or offline: `--package <zip>` or an
`ii-windows-<version>.zip` next to the exe (with its `.sha256` next to it, it's verified too).
Update offers use the version parsed from the selected zip, including a hotfix suffix, rather than
assuming that it matches the release tag.
`IIW_SETUP_RELEASE_JSON=<url>` replaces the GitHub API with a release JSON of the same shape
(testing hook; used on the VM with a loopback server to test download + checksum rejection).

Expand Down
23 changes: 22 additions & 1 deletion installer/core/src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ pub fn parse_release(json: &serde_json::Value, wanted_arch: Arch) -> Result<Rele
let zip_name = name_of(zip);
let url =
|a: &serde_json::Value| a.get("browser_download_url").and_then(|v| v.as_str()).unwrap_or_default().to_string();
let version = version::from_package_name(&zip_name).filter(|_| ver.is_empty()).unwrap_or(ver);
let version = version::from_package_name(&zip_name).unwrap_or(ver);
let setup = find(crate::SETUP_EXE);
let setup_sha256 = setup
.and_then(|a| a.get("digest"))
Expand Down Expand Up @@ -400,6 +400,27 @@ mod tests {
assert_eq!(parse_release(&renamed, Arch::Arm64).unwrap().zip_name, "ii-windows-26.1.2.0-fix1-arm64.zip");
}

#[test]
fn selected_zip_version_drives_updates() {
let hotfix = parse_release(
&release(&["ii-windows-26.1.2.0-fix1.zip", "ii-windows-26.1.2.0-fix1.zip.sha256"]),
Arch::X64,
)
.unwrap();
assert_eq!(hotfix.tag, "v26.1.2.0");
assert_eq!(hotfix.version, "26.1.2.0-fix1");
assert!(version::is_newer(&hotfix.version, "26.1.2.0"));

let stale = parse_release(
&release(&["ii-windows-26.1.1.0.zip", "ii-windows-26.1.1.0.zip.sha256"]),
Arch::X64,
)
.unwrap();
assert_eq!(stale.tag, "v26.1.2.0");
assert_eq!(stale.version, "26.1.1.0");
assert!(!version::is_newer(&stale.version, "26.1.1.0"));
}

#[test]
fn arm64_falls_back_to_x64() {
let old = release(&["ii-windows-setup.exe", "ii-windows-26.1.2.0.zip", "ii-windows-26.1.2.0.zip.sha256"]);
Expand Down
9 changes: 9 additions & 0 deletions tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ if [ "$CARGO_VERSION" != "$VERSION" ] && [ "$CARGO_VERSION" != "$CARGO_EXPECTED"
exit 1
fi

if [ "${GITHUB_EVENT_NAME:-}" = push ] && [ "${GITHUB_REF_TYPE:-}" = tag ]; then
TAG_VERSION="${GITHUB_REF_NAME#v}"
OLDEST="$(printf '%s\n' "$TAG_VERSION" "$VERSION" | sort -V | head -n1)"
if [ "$VERSION" != "$TAG_VERSION" ] && [ "$OLDEST" = "$VERSION" ]; then
echo "VERSION says $VERSION, older than release tag $GITHUB_REF_NAME" >&2
exit 1
fi
fi

if [ "${SKIP_SETUP_BUILD:-}" != 1 ]; then
(cd "$IIW/installer" && cargo xwin build --release --target x86_64-pc-windows-msvc -p ii-windows-setup)
fi
Expand Down
Loading