diff --git a/.run_status.toml b/.run_status.toml index ab1db7e..3005272 100644 --- a/.run_status.toml +++ b/.run_status.toml @@ -4,8 +4,8 @@ lines_parsed = 440 coverage = 92.72 [last_run_clean.run_duration] -secs = 62 -nanos = 51839113 +secs = 61 +nanos = 703714737 [last_run_incremental] run_status = "Success" diff --git a/docs/releasing.md b/docs/releasing.md index b080439..31e4d01 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -52,10 +52,10 @@ then pass the path of a readable Gitea token file to the repository wrapper: The wrapper keeps the token out of command-line arguments, exports it as `GITEA_TOKEN` only to `rust_realease`, selects the `john-slop` workspace package, -and publishes cargo-binstall archives alongside raw binary artifacts. It -temporarily selects the canonical HTTPS -origin for publication, then restores the SSH development origin after both -successful and failed attempts. A hyphenated Cargo version such as +and publishes cargo-binstall archives alongside raw binary artifacts. The +project-local `rust-release.toml` maps the SSH development origin to the +canonical HTTPS proxy for release API and download operations without modifying +the Git remote. A hyphenated Cargo version such as `0.1.27-rc.6` automatically marks the Gitea release as a prerelease. Additional arguments are forwarded, so use `--dry-run` before publication and `--replace-assets` only after reviewing an existing release collision. The diff --git a/release.sh b/release.sh index 8f2868e..ca347a0 100755 --- a/release.sh +++ b/release.sh @@ -30,32 +30,6 @@ export GITEA_TOKEN repository_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) manifest_version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' "$repository_dir/Cargo.toml" | head -n 1) -release_origin=https://proxy.dandaedre.com/gitea/idle-org/john-slop -development_origin=git@git.dandaedre.com:idle-org/john-slop.git - -if ! git -C "$repository_dir" remote get-url origin >/dev/null 2>&1; then - echo "Git origin is not configured for $repository_dir" >&2 - exit 2 -fi - -origin_switched=false -restore_development_origin() { - if [ "$origin_switched" = true ]; then - if git -C "$repository_dir" remote set-url origin "$development_origin"; then - origin_switched=false - else - echo "error: failed to restore Git origin to $development_origin" >&2 - return 1 - fi - fi -} - -git -C "$repository_dir" remote set-url origin "$release_origin" -origin_switched=true -trap 'restore_development_origin || :' 0 -trap 'exit 129' 1 -trap 'exit 130' 2 -trap 'exit 143' 15 set -- \ "$repository_dir" \ @@ -66,10 +40,4 @@ case "$manifest_version" in *-*) set -- "$@" --prerelease ;; esac -release_status=0 -rust_realease "$@" || release_status=$? -if ! restore_development_origin; then - exit 2 -fi -trap - 0 1 2 15 -exit "$release_status" +exec rust_realease "$@" diff --git a/rust-release.toml b/rust-release.toml new file mode 100644 index 0000000..9819f36 --- /dev/null +++ b/rust-release.toml @@ -0,0 +1,3 @@ +[[repository.fallbacks]] +origin = "git@git.dandaedre.com:idle-org/john-slop.git" +fallback-url = "https://proxy.dandaedre.com/gitea/idle-org/john-slop" diff --git a/tests/release_wrapper.rs b/tests/release_wrapper.rs index e3ad642..f37735f 100644 --- a/tests/release_wrapper.rs +++ b/tests/release_wrapper.rs @@ -9,8 +9,10 @@ use std::{ use tempfile::TempDir; -const RELEASE_ORIGIN: &str = "https://proxy.dandaedre.com/gitea/idle-org/john-slop"; const DEVELOPMENT_ORIGIN: &str = "git@git.dandaedre.com:idle-org/john-slop.git"; +const RELEASE_CONFIG: &str = "[[repository.fallbacks]]\n\ +origin = \"git@git.dandaedre.com:idle-org/john-slop.git\"\n\ +fallback-url = \"https://proxy.dandaedre.com/gitea/idle-org/john-slop\"\n"; fn run(command: &mut Command) -> Output { command.output().expect("test command should start") @@ -24,7 +26,7 @@ fn git(repository: &Path, arguments: &[&str]) -> Output { } #[test] -fn release_wrapper_uses_https_then_restores_ssh_on_every_exit() { +fn release_wrapper_uses_repository_fallback_without_changing_origin() { for release_status in [0, 17] { let temporary = TempDir::new().expect("temporary directory should be created"); let repository = temporary.path().join("repository"); @@ -37,6 +39,11 @@ fn release_wrapper_uses_https_then_restores_ssh_on_every_exit() { repository.join("release.sh"), ) .expect("release wrapper should be copied"); + fs::copy( + Path::new(env!("CARGO_MANIFEST_DIR")).join("rust-release.toml"), + repository.join("rust-release.toml"), + ) + .expect("release configuration should be copied"); fs::write( repository.join("Cargo.toml"), "[package]\nname = \"john-slop\"\nversion = \"0.1.27-rc.6\"\n", @@ -51,6 +58,7 @@ fn release_wrapper_uses_https_then_restores_ssh_on_every_exit() { "#!/bin/sh\n\ [ \"$GITEA_TOKEN\" = test-token ] || exit 91\n\ git -C \"$1\" remote get-url origin >\"$OBSERVED_ORIGIN\"\n\ + cat \"$1/rust-release.toml\" >\"$OBSERVED_CONFIG\"\n\ printf '%s\\n' \"$@\" >\"$OBSERVED_ARGS\"\n\ exit \"$FAKE_RELEASE_STATUS\"\n", ) @@ -73,6 +81,7 @@ fn release_wrapper_uses_https_then_restores_ssh_on_every_exit() { ); let observed_origin = temporary.path().join("observed-origin.txt"); + let observed_config = temporary.path().join("observed-config.toml"); let observed_args = temporary.path().join("observed-args.txt"); let path = format!( "{}:{}", @@ -84,6 +93,7 @@ fn release_wrapper_uses_https_then_restores_ssh_on_every_exit() { .arg("--dry-run") .env("PATH", path) .env("OBSERVED_ORIGIN", &observed_origin) + .env("OBSERVED_CONFIG", &observed_config) .env("OBSERVED_ARGS", &observed_args) .env("FAKE_RELEASE_STATUS", release_status.to_string())); @@ -92,7 +102,12 @@ fn release_wrapper_uses_https_then_restores_ssh_on_every_exit() { fs::read_to_string(&observed_origin) .expect("fake release should record the temporary origin") .trim(), - RELEASE_ORIGIN + DEVELOPMENT_ORIGIN + ); + assert_eq!( + fs::read_to_string(&observed_config) + .expect("fake release should record the project configuration"), + RELEASE_CONFIG ); assert_eq!( String::from_utf8(git(&repository, &["remote", "get-url", "origin"]).stdout)