1
- name : Publish to crates.io
1
+ name : " Publish to crates.io"
2
2
3
3
on :
4
4
push :
5
5
branches :
6
6
- ' !**'
7
7
tags :
8
- - ' 0.9.[0-9]+'
9
- - ' 0.10.[0-9]+'
8
+ - ' 0.10.[0-9]+-?*'
10
9
11
10
env :
12
11
GDRUST_FEATURES : " gdnative/async,gdnative/serde"
13
12
13
+ # Crates to publish -- important, this doesn't work when there are spaces in any of the paths!
14
+ GDRUST_CRATES : >
15
+ impl/proc-macros
16
+ gdnative-sys
17
+ gdnative-derive
18
+ gdnative-core
19
+ bindings-generator
20
+ gdnative-bindings
21
+ gdnative-async
22
+ gdnative
23
+
14
24
defaults :
15
25
run :
16
26
shell : bash
17
27
18
28
jobs :
19
- publish :
29
+ validation :
20
30
runs-on : ubuntu-latest
21
- environment : Deploy
22
31
steps :
23
32
- uses : actions/checkout@v2
24
33
25
- - uses : actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f
34
+ # sed: https://unix.stackexchange.com/a/589584
35
+ - name : " Interpret tag version"
36
+ run : |
37
+ version=$(echo "$GITHUB_REF" | sed -n "s#refs/tags/\(.*\)#\1#p")
38
+ [ -z "$version" ] && {
39
+ printf "\nError: Failed to parse '$GITHUB_REF'.\n"
40
+ exit 2
41
+ }
42
+
43
+ echo "Published version: $version"
44
+ echo "GDRUST_PUBLISHED_VERSION=$version" >> $GITHUB_ENV
45
+
46
+ - name : " Verify that Cargo.toml versions match ${{ env.GDRUST_PUBLISHED_VERSION }}"
47
+ run : |
48
+ echo "Checking crate versions..."
49
+
50
+ # Check if each Cargo.toml has that version
51
+ IFS=' ' read -r -a publishedCrates <<< "$GDRUST_CRATES"
52
+ for crate in "${publishedCrates[@]}"; do
53
+ readVersion=$(grep -Po '^version = "\K[^"]*' "$crate/Cargo.toml")
54
+ printf "* $crate -> $readVersion"
55
+
56
+ if [[ "$readVersion" != "$GDRUST_PUBLISHED_VERSION" ]]; then
57
+ printf " ERROR\n"
58
+ versionMismatch="1"
59
+ else
60
+ printf "\n"
61
+ fi
62
+ done
63
+
64
+ if [[ -n "$versionMismatch" ]]; then
65
+ printf "\nError: At least one crate has a version mismatching the git tag.\n"
66
+ exit 2
67
+ else
68
+ printf "\nAll versions OK.\n"
69
+ fi
70
+
71
+ test :
72
+ runs-on : ubuntu-latest
73
+ needs : validation
74
+ steps :
75
+ - uses : actions/checkout@v2
76
+ - uses : actions-rs/toolchain@v1
26
77
with :
27
78
profile : minimal
28
79
toolchain : stable
29
- components : rustfmt, clippy
80
+ override : true
81
+ - name : " Compile tests"
82
+ run : cargo test --workspace --features ${GDRUST_FEATURES} --no-run
83
+ - name : " Test"
84
+ run : cargo test --workspace --features ${GDRUST_FEATURES}
30
85
31
- - name : " Sanity tests"
32
- run : |
33
- cargo fmt --all -- --check;
34
- cargo clippy --workspace --features ${GDRUST_FEATURES} -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented;
35
- cargo test --workspace --features ${GDRUST_FEATURES};
86
+ clippy :
87
+ runs-on : ubuntu-latest
88
+ needs : validation
89
+ steps :
90
+ - uses : actions/checkout@v2
91
+ - uses : actions-rs/toolchain@v1
92
+ with :
93
+ profile : minimal
94
+ toolchain : stable
95
+ override : true
96
+ components : clippy
97
+ - name : " Check clippy"
98
+ run : cargo clippy --workspace --features ${GDRUST_FEATURES} -- -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented
99
+
100
+ rustfmt :
101
+ runs-on : ubuntu-latest
102
+ needs : validation
103
+ steps :
104
+ - uses : actions/checkout@v2
105
+ - uses : actions-rs/toolchain@v1
106
+ with :
107
+ profile : minimal
108
+ toolchain : stable
109
+ override : true
110
+ components : rustfmt
111
+ - name : " Check rustfmt"
112
+ run : cargo fmt --all -- --check
36
113
37
- - name : " Publish to crates.io"
114
+ publish :
115
+ runs-on : ubuntu-latest
116
+ environment : Deploy
117
+ needs : [test, clippy, rustfmt]
118
+ steps :
119
+ # Note: we cannot dry-run the publishing, since crates depend on each other, and dry-run will fail if they aren't yet on crates.io.
120
+ # Sleep to leave crates.io and docs.rs some time to index the dependencies, before releasing dependents.
121
+ - uses : actions/checkout@v2
122
+ - name : " Execute crates.io publishing"
38
123
env :
39
124
CARGO_REGISTRY_TOKEN : ${{ secrets.CARGO_TOKEN }}
40
125
run : |
41
- (cd impl/proc-macros && cargo publish);
42
- sleep 1m;
43
- (cd gdnative-sys && cargo publish);
44
- sleep 1m;
45
- (cd gdnative-derive && cargo publish);
46
- sleep 1m;
47
- (cd gdnative-core && cargo publish);
48
- sleep 1m;
49
- (cd bindings-generator && cargo publish);
50
- sleep 1m;
51
- (cd gdnative-bindings && cargo publish);
52
- sleep 1m;
53
- (cd gdnative-async && cargo publish);
54
- sleep 1m;
55
- (cd gdnative && cargo publish);
126
+ IFS=' ' read -r -a publishedCrates <<< "$GDRUST_CRATES"
127
+ for crate in "${publishedCrates[@]}"; do
128
+ (cd "$crate" && cargo publish) || {
129
+ printf "\nError: Failed to publish $crate\n"
130
+ exit 2
131
+ }
132
+ sleep 40s
133
+ done
0 commit comments