1
+ # Copyright (c) godot-rust; Bromeon and contributors.
2
+ # This Source Code Form is subject to the terms of the Mozilla Public
3
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ # file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+
1
6
name : " Release workflow"
2
7
3
8
on :
4
9
push :
5
- branches :
6
- - ' !**'
7
- tags :
8
- # To include pre-releases: 'v0.1.[0-9]+-?*'
9
- - ' v0.1.[0-9]+'
10
+ # branches:
11
+ # - '!**'
12
+ # tags:
13
+ # # To include pre-releases: 'v0.1.[0-9]+-?*'
14
+ # - 'v0.1.[0-9]+'
10
15
11
16
env :
12
17
# Note: used for test and clippy, not for publish
@@ -30,32 +35,37 @@ defaults:
30
35
jobs :
31
36
validation :
32
37
runs-on : ubuntu-latest
38
+ outputs :
39
+ GDEXT_PUBLISHED_VERSION : ${{ steps.interpret-tag-version.outputs.GDEXT_PUBLISHED_VERSION }}
33
40
steps :
34
41
- uses : actions/checkout@v4
35
42
36
43
# sed: https://unix.stackexchange.com/a/589584
37
44
- name : " Interpret tag version"
45
+ id : interpret-tag-version
38
46
run : |
39
- version=$(echo "$GITHUB_REF" | sed -n "s#refs/tags/v\(.*\)#\1#p")
47
+ #version=$(echo "$GITHUB_REF" | sed -n "s#refs/tags/v\(.*\)#\1#p")
48
+ version="0.1.0" # DEBUG
40
49
[ -z "$version" ] && {
41
50
printf "\n::error::Failed to parse '$GITHUB_REF'.\n"
42
51
exit 2
43
52
}
44
53
45
54
echo "Published version: $version"
46
- echo "GDEXT_PUBLISHED_VERSION=$version" >> $GITHUB_ENV
55
+ echo "GDEXT_PUBLISHED_VERSION=$version" >> $GITHUB_OUTPUT
47
56
48
- - name : " Verify that Cargo.toml versions match ${{ env .GDEXT_PUBLISHED_VERSION }}"
57
+ - name : " Verify that Cargo.toml versions match ${{ steps.interpret-tag-version.outputs .GDEXT_PUBLISHED_VERSION }}"
49
58
run : |
50
59
echo "Checking crate versions..."
60
+ publishedVersion="${{ steps.interpret-tag-version.outputs.GDEXT_PUBLISHED_VERSION }}"
51
61
52
62
# Check if each Cargo.toml has that version
53
63
IFS=' ' read -r -a publishedCrates <<< "$GDEXT_CRATES"
54
64
for crate in "${publishedCrates[@]}"; do
55
65
readVersion=$(grep -Po '^version = "\K[^"]*' "$crate/Cargo.toml")
56
66
printf "* $crate -> $readVersion"
57
67
58
- if [[ "$readVersion" != "$GDEXT_PUBLISHED_VERSION " ]]; then
68
+ if [[ "$readVersion" != "$publishedVersion " ]]; then
59
69
printf " ERROR\n"
60
70
versionMismatch="1"
61
71
else
@@ -128,17 +138,57 @@ jobs:
128
138
exit 1
129
139
}
130
140
131
- publish :
141
+ docs-and-commit :
132
142
runs-on : ubuntu-latest
133
- # environment: 'Crates.io'
134
143
needs :
144
+ - validation
135
145
- unit-test
136
146
- clippy
137
147
- rustfmt
148
+ env :
149
+ GDEXT_PUBLISHED_VERSION : ${{ needs.validation.outputs.GDEXT_PUBLISHED_VERSION }}
150
+ steps :
151
+ - uses : actions/checkout@v4
152
+
153
+ - name : " Install Rust (uncached)"
154
+ run : rustup update stable
155
+
156
+ - name : " Commit raw changes"
157
+ run : |
158
+ # Backup current repo, so we can checkout.
159
+ mkdir -p /tmp/repo
160
+ rsync -av --exclude .git --exclude target ./ /tmp/repo/
161
+ git switch releases || git switch --orphan releases
162
+ find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
163
+ # Restore.
164
+ rsync -av --ignore-existing /tmp/repo/ .
165
+
166
+ # Commit.
167
+ git config user.name "Godot-Rust Automation"
168
+ git config user.email "[email protected] "
169
+ git add .
170
+ git commit -m "Repo state for v${{ env.GDEXT_PUBLISHED_VERSION }}."
171
+
172
+ - name : " Apply #[doc(cfg(...))]"
173
+ run : .github/other/apply-doc-cfg.sh --install-sd --rustfmt
174
+
175
+ - name : " Commit post-processed changes"
176
+ run : git commit -am "Postprocess docs for v${{ env.GDEXT_PUBLISHED_VERSION }}."
177
+
178
+ - name : " Push changes"
179
+ run : git push origin releases
180
+
181
+ publish :
182
+ runs-on : ubuntu-latest
183
+ # environment: 'Crates.io'
184
+ needs :
185
+ - docs-and-commit
138
186
steps :
139
187
# 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.
140
188
# Sleep to leave crates.io and docs.rs some time to index the dependencies, before releasing dependents.
141
189
- uses : actions/checkout@v4
190
+ with :
191
+ ref : releases
142
192
143
193
- name : " Install Rust (uncached)"
144
194
run : rustup update stable
0 commit comments