Skip to content

Commit 5708c35

Browse files
committed
Split crates.io fetch logic from SemVer action
1 parent 10129fe commit 5708c35

File tree

2 files changed

+43
-36
lines changed

2 files changed

+43
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cedar_policy_version="$(
5+
cd head &&
6+
cargo metadata --format-version 1 |
7+
jq --raw-output '.packages[] | select(.name == "cedar-policy") | .version'
8+
)"
9+
echo "HEAD has cedar-policy at ${cedar_policy_version}"
10+
11+
tmp_dir="$(mktemp -d)"
12+
function cleanup {
13+
rm -rf "${tmp_dir}"
14+
}
15+
trap cleanup EXIT
16+
17+
(
18+
cd "${tmp_dir}"
19+
20+
cat <<EOF >Cargo.toml
21+
[package]
22+
name = "cedar-semver-checks"
23+
version = "0.0.0"
24+
edition = "2021"
25+
publish = false
26+
27+
[dependencies]
28+
cedar-policy = "<=${cedar_policy_version}"
29+
EOF
30+
31+
mkdir src
32+
touch src/lib.rs
33+
34+
cargo vendor
35+
)
36+
37+
mkdir base
38+
mv "${tmp_dir}/vendor/cedar-policy" base/
39+
cat <<EOF >base/Cargo.toml
40+
[workspace]
41+
members = ["cedar-policy"]
42+
EOF

.github/workflows/ci.yml

+1-36
Original file line numberDiff line numberDiff line change
@@ -64,43 +64,8 @@ jobs:
6464
# published to crates.io <= the version from head.
6565
- if: ${{ startsWith(github.base_ref, 'release/') }}
6666
name: Check out base (from crates.io)
67+
run: head/.github/scripts/check-out-base-from-crates-io.sh
6768
shell: bash
68-
run: |-
69-
cedar_policy_version="$(
70-
cd head &&
71-
cargo metadata --format-version 1 |
72-
jq --raw-output '.packages[] | select(.name == "cedar-policy") | .version'
73-
)"
74-
echo "HEAD has cedar-policy at ${cedar_policy_version}"
75-
76-
tmp_dir="$(mktemp -d)"
77-
function cleanup {
78-
rm -rf "${tmp_dir}"
79-
}
80-
trap cleanup EXIT
81-
82-
(
83-
cd "${tmp_dir}"
84-
85-
echo "[package]
86-
name = \"cedar-semver-checks\"
87-
version = \"0.0.0\"
88-
edition = \"2021\"
89-
publish = false
90-
91-
[dependencies]
92-
cedar-policy = \"<=${cedar_policy_version}\"" > Cargo.toml
93-
94-
mkdir src
95-
touch src/lib.rs
96-
97-
cargo vendor
98-
)
99-
100-
mkdir base
101-
mv "${tmp_dir}/vendor/cedar-policy" base/
102-
echo '[workspace]
103-
members = ["cedar-policy"]' > base/Cargo.toml
10469
# `cargo semver-checks` doesn't understand `rlib` crates.
10570
- run: >-
10671
sed -i 's/^crate_type = \["rlib"\]$/crate_type = ["lib"]/' {head,base}/cedar-policy/Cargo.toml

0 commit comments

Comments
 (0)