Skip to content

Commit 5d0b766

Browse files
committed
feat(ci): ensure the tag is actually checked out
Signed-off-by: Sven Kanoldt <sven@d34dl0ck.me>
1 parent 9586143 commit 5d0b766

1 file changed

Lines changed: 49 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,22 @@ on:
1414

1515
jobs:
1616
doing-a-build:
17-
uses: steganogram/stegano-rs/.github/workflows/build.yml@main
18-
secrets:
17+
needs: determine-crate
18+
runs-on: ubuntu-latest
19+
env:
1920
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
21+
steps:
22+
- name: Checkout release tag for build
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
ref: refs/tags/${{ needs.determine-crate.outputs.tag }}
27+
- name: setup | rust
28+
uses: dtolnay/rust-toolchain@stable
29+
- name: cargo build
30+
run: cargo build --workspace --verbose
31+
- name: cargo test
32+
run: cargo test --workspace --verbose
2033

2134
determine-crate:
2235
name: Determine crate and version from tag
@@ -26,10 +39,11 @@ jobs:
2639
version: ${{ steps.parse.outputs.version }}
2740
tag: ${{ steps.parse.outputs.tag }}
2841
steps:
29-
- name: Checkout
42+
- name: Checkout (fetch tags)
3043
uses: actions/checkout@v4
3144
with:
32-
fetch-depth: 1
45+
# Fetch tags so we can checkout the tagged ref later
46+
fetch-depth: 0
3347

3448
- id: parse
3549
name: Parse tag and validate crate
@@ -52,6 +66,28 @@ jobs:
5266
5367
echo "Resolved tag: ${TAG}"
5468
69+
# Ensure the tag exists locally and check it out so validation matches the released source
70+
# Fetch tags from origin and try to checkout the tag ref.
71+
git fetch --prune --tags origin || true
72+
73+
# Try to checkout the annotated/tag ref directly; fall back to tag name
74+
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
75+
git checkout -f "refs/tags/${TAG}"
76+
else
77+
# attempt shallow fetch of the specific tag and checkout by tag name
78+
git fetch --depth=1 origin "refs/tags/${TAG}:refs/tags/${TAG}" || true
79+
git checkout -f "${TAG}" || true
80+
fi
81+
82+
# After checking out the tag, confirm the working tree matches the requested tag
83+
CURRENT_TAG=$(git describe --tags --exact-match 2>/dev/null || true)
84+
if [ -n "${CURRENT_TAG}" ]; then
85+
echo "Checked out tag: ${CURRENT_TAG}"
86+
else
87+
# best-effort warning but continue; subsequent validations will fail if files missing
88+
echo "Warning: could not verify that the tag was checked out exactly. Proceeding with repository state."
89+
fi
90+
5591
# Expect tags of the form <crate>-v<version>, e.g. stegano-cli-v0.6.1
5692
if [[ "${TAG}" =~ ^(.+)-v(.+)$ ]]; then
5793
CRATE="${BASH_REMATCH[1]}"
@@ -61,9 +97,9 @@ jobs:
6197
exit 1
6298
fi
6399
64-
# Validate crate directory exists
100+
# Validate crate directory exists (now using the checked-out tag)
65101
if [ ! -f "crates/${CRATE}/Cargo.toml" ]; then
66-
echo "Crate 'crates/${CRATE}' does not exist in the repository."
102+
echo "Crate 'crates/${CRATE}' does not exist in the repository at tag ${TAG}."
67103
exit 1
68104
fi
69105
@@ -77,7 +113,11 @@ jobs:
77113
needs: [doing-a-build, determine-crate]
78114
runs-on: ubuntu-latest
79115
steps:
80-
- uses: actions/checkout@v4
116+
- name: Checkout release tag
117+
uses: actions/checkout@v4
118+
with:
119+
fetch-depth: 0
120+
ref: refs/tags/${{ needs.determine-crate.outputs.tag }}
81121
- name: setup | rust
82122
uses: dtolnay/rust-toolchain@stable
83123

@@ -97,6 +137,8 @@ jobs:
97137
runs-on: ubuntu-latest
98138
steps:
99139
- uses: actions/checkout@v4
140+
with:
141+
ref: ${{ needs.determine-crate.outputs.tag }}
100142
- name: setup | rust
101143
uses: dtolnay/rust-toolchain@stable
102144

0 commit comments

Comments
 (0)