Skip to content

Commit 288d96e

Browse files
committed
fix: updates to workflow to check tags
1 parent 1619d96 commit 288d96e

File tree

1 file changed

+28
-34
lines changed

1 file changed

+28
-34
lines changed

.github/workflows/release.yaml

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ env:
1515
RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu
1616
RUST_VERSION: "1.85"
1717
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
18+
TAG: ${{ github.ref_name }}
1819

1920
jobs:
2021
## Concordium Rust SDK Release Build
@@ -30,48 +31,41 @@ jobs:
3031
with:
3132
submodules: recursive
3233

33-
# RustFmt checks
34-
- name: Rust format checks
34+
# Check git tag is present on the main branch and matches expected version from Cargo.toml and
35+
- name: Check git tag
3536
run: |
36-
rustup default $RUST_FMT
37-
rustup component add rustfmt
38-
cargo fmt -- --color=always --check
3937
40-
# Compilation Check
41-
- name: Compilation Check
42-
run: |
43-
rustup default $RUST_VERSION
44-
cargo check --all-targets --all-features
45-
46-
# Clippy checks
47-
- name: Clippy
48-
run: |
49-
rustup default $RUST_VERSION
50-
rustup component add clippy
51-
cargo clippy --color=always --all-targets --all-features -- -D warnings
52-
# Examples can be large with a lot of debug info due to tokio. So we
53-
# disable debug info generation.
54-
RUSTFLAGS="-C debuginfo=0" cargo test --all-targets --all-features
55-
56-
## Probably not needed
57-
#- name: Build Rust SDK
58-
# run: |
59-
# echo "Building Concordium Rust SDK..."
60-
# cargo build --release
38+
# first check if the tag is in the expected release Format and is on the main branch, extract the version from the tag
39+
echo "Checking the following git tag: ${{ env.TAG }}"
40+
TAG_VERSION_NUMBER=${TAG##release/concordium-rust-sdk/}
41+
echo "<TODO> - main branch check here"
6142
62-
#- name: Run Tests
63-
# run: cargo test --release
43+
# extract the expected version from Cargo.toml
44+
EXPECTED_VERSION_FROM_CARGO=$(yq .package.version ./Cargo.toml)
45+
echo "Expected version from Cargo.toml: $EXPECTED_VERSION_FROM_CARGO"
6446
47+
# Ensure the tagged version number matches the expected version from Cargo.toml
48+
if [ "$TAG_VERSION_NUMBER" != "$EXPECTED_VERSION_FROM_CARGO" ]; then
49+
echo "Tag version number ($TAG_VERSION_NUMBER) does not match expected version from Cargo.toml ($EXPECTED_VERSION_FROM_CARGO). Exiting.";
50+
exit 1;
51+
else
52+
echo "Tag version number matches expected version from Cargo.toml. Proceeding with release.";
53+
fi
6554
66-
# Publish to crates.io (dry run)
67-
- name: Dry run Publish to crates.io
55+
# Check version number does not already exist in crates.io
56+
- name: Check if version exists in crates.io
6857
run: |
69-
cargo publish --dry-run
70-
cargo package --list
58+
echo "Checking if version already exists in crates.io..."
59+
if cargo search concordium-rust-sdk | grep -q '"version":'; then
60+
echo "Version already exists in crates.io. Exiting.";
61+
exit 1;
62+
else
63+
echo "Version does not exist in crates.io. Proceeding with release.";
64+
fi
7165
7266
# Publish to crates.io
7367
- name: Publish to crates.io
7468
run: |
7569
# Uncomment the next line to actually publish
76-
echo "Publishing Concordium Rust SDK to crates.io..."
77-
# cargo publish --token $CARGO_REGISTRY_TOKEN
70+
echo "Publishing Concordium Rust SDK to crates.io for version: $TAG_VERSION"
71+
# cargo publish --token $CARGO_REGISTRY_TOKEN --locked

0 commit comments

Comments
 (0)