diff --git a/.github/workflows/delete-release.yml b/.github/workflows/delete-release.yml index 4660dca..9e4c0c7 100644 --- a/.github/workflows/delete-release.yml +++ b/.github/workflows/delete-release.yml @@ -45,9 +45,22 @@ jobs: - uses: actions/checkout@v5 with: fetch-depth: 0 + token: ${{ github.token }} - uses: dtolnay/rust-toolchain@stable + - name: Validate source ref + env: + REF_NAME: ${{ github.ref_name }} + shell: bash + run: | + set -euo pipefail + + if [ "${REF_NAME}" != "master" ]; then + echo "::error::Delete Release must be run from master. Current ref: ${REF_NAME}" + exit 1 + fi + - name: Bootstrap github-release run: | cargo build --release -p github-release diff --git a/crates/github-release/src/github.rs b/crates/github-release/src/github.rs index 5196635..150e33e 100644 --- a/crates/github-release/src/github.rs +++ b/crates/github-release/src/github.rs @@ -1530,6 +1530,51 @@ mod tests { ); } + #[test] + fn rollback_analysis_reuses_remaining_stable_release_when_exact_tag_is_missing() { + let tags = vec![ + "v0".to_string(), + "v0.3".to_string(), + "v0.3.0".to_string(), + "v0.4".to_string(), + "v0.4.0-rc.1".to_string(), + "latest".to_string(), + "next".to_string(), + ]; + let analysis = analyze_floating_tags(&tags, "v", ""); + + assert_eq!( + analysis.latest_stable.as_ref().expect("latest stable").1, + "v0.3.0" + ); + assert_eq!( + analysis.next_preview.as_ref().expect("next preview").1, + "v0.4.0-rc.1" + ); + assert_eq!( + stale_stable_floating_tags(&tags, &analysis, "v", ""), + vec!["v0.4".to_string()] + ); + } + + #[test] + fn expected_stable_floating_tags_drop_removed_minor_line_after_rollback() { + let tags = vec![ + "v0".to_string(), + "v0.3".to_string(), + "v0.3.0".to_string(), + "v0.4".to_string(), + "v0.4.0-rc.1".to_string(), + ]; + let analysis = analyze_floating_tags(&tags, "v", ""); + let expected = expected_stable_floating_tags(&analysis, "v", ""); + + assert_eq!( + expected, + HashSet::from(["v0".to_string(), "v0.3".to_string()]) + ); + } + #[test] fn stable_floating_tag_detection_respects_prefix_and_suffix() { let tags = vec![