@@ -7,6 +7,12 @@ name: "Release workflow"
7
7
8
8
on :
9
9
push :
10
+ workflow_dispatch :
11
+ inputs :
12
+ skip-release :
13
+ description : " Enter 'y' to skip release to crates.io"
14
+ default : " "
15
+ required : false
10
16
# branches:
11
17
# - '!**'
12
18
# tags:
@@ -36,28 +42,33 @@ jobs:
36
42
validation :
37
43
runs-on : ubuntu-latest
38
44
outputs :
39
- GDEXT_PUBLISHED_VERSION : ${{ steps.interpret-tag -version.outputs.GDEXT_PUBLISHED_VERSION }}
45
+ GDEXT_PUBLISHED_VERSION : ${{ steps.parse-crate -version.outputs.GDEXT_PUBLISHED_VERSION }}
40
46
steps :
41
47
- uses : actions/checkout@v4
42
48
43
- # sed: https://unix.stackexchange.com/a/589584
44
- - name : " Interpret tag version"
45
- id : interpret-tag-version
49
+ - name : " Parse crate version from Cargo.toml"
50
+ id : parse-crate-version
46
51
run : |
47
- #version=$(echo "$GITHUB_REF" | sed -n "s#refs/tags/v\(.*\)#\1#p")
48
- version="0.1.0" # DEBUG
49
- [ -z "$version" ] && {
50
- printf "\n::error::Failed to parse '$GITHUB_REF'.\n"
52
+ crateVer=$(grep -Po '^version = "\K[^"]*' godot/Cargo.toml)
53
+ if [[ -z "$crateVer" ]]; then
54
+ echo "::error::Failed to parse crate version from godot/Cargo.toml."
55
+ exit 1
56
+ fi
57
+
58
+ # Check if tag exists.
59
+ git fetch --tags
60
+ if git tag -l | grep -q "^v$crateVer$" ; then
61
+ echo "::error::Tag 'v$crateVer' already exists."
51
62
exit 2
52
- }
63
+ fi
53
64
54
- echo "Published version: $version"
55
- echo "GDEXT_PUBLISHED_VERSION=$ version" >> $GITHUB_OUTPUT
65
+ echo "GDEXT_PUBLISHED_VERSION=$crateVer" >> $GITHUB_OUTPUT
66
+ echo "Validated version: $crateVer"
56
67
57
- - name : " Verify that Cargo.toml versions match ${{ steps.interpret-tag -version.outputs.GDEXT_PUBLISHED_VERSION }}"
68
+ - name : " Verify that Cargo.toml versions match ${{ steps.parse-crate -version.outputs.GDEXT_PUBLISHED_VERSION }}"
58
69
run : |
59
70
echo "Checking crate versions..."
60
- publishedVersion="${{ steps.interpret-tag -version.outputs.GDEXT_PUBLISHED_VERSION }}"
71
+ publishedVersion="${{ steps.parse-crate -version.outputs.GDEXT_PUBLISHED_VERSION }}"
61
72
62
73
# Check if each Cargo.toml has that version
63
74
IFS=' ' read -r -a publishedCrates <<< "$GDEXT_CRATES"
@@ -158,7 +169,7 @@ jobs:
158
169
# Backup current repo, so we can checkout.
159
170
mkdir -p /tmp/repo
160
171
rsync -av --exclude .git --exclude target ./ /tmp/repo/
161
- git switch releases || git switch --orphan releases
172
+ git fetch origin releases && git switch releases || git switch --orphan releases
162
173
find . -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
163
174
# Restore.
164
175
rsync -av --ignore-existing /tmp/repo/ .
@@ -167,19 +178,25 @@ jobs:
167
178
git config user.name "Godot-Rust Automation"
168
179
git config user.email "[email protected] "
169
180
git add .
170
- git commit -m "Repo state for v${{ env.GDEXT_PUBLISHED_VERSION }}. "
181
+ git commit -m "Repo state for v${{ env.GDEXT_PUBLISHED_VERSION }}"
171
182
172
183
- name : " Apply #[doc(cfg(...))]"
173
- run : .github/other/apply-doc-cfg.sh --install-sd --rustfmt
184
+ # Skip --rustfmt, as it causes weird reformatting of quote! {} statements.
185
+ # #[doc(cfg(...))] on the same line is the lesser evil.
186
+ run : .github/other/apply-doc-cfg.sh --install-sd
174
187
175
188
- name : " Commit post-processed changes"
176
- run : git commit -am "Postprocess docs for v${{ env.GDEXT_PUBLISHED_VERSION }}. "
189
+ run : git commit -am "Postprocess docs for v${{ env.GDEXT_PUBLISHED_VERSION }}"
177
190
178
- - name : " Push changes"
179
- run : git push origin releases
191
+ - name : " Push changes + tag version"
192
+ run : |
193
+ versionTag="v$GDEXT_PUBLISHED_VERSION"
194
+ git tag "$versionTag"
195
+ git push origin releases "$versionTag"
180
196
181
197
publish :
182
198
runs-on : ubuntu-latest
199
+ if : ${{ github.event.inputs.skip-release != 'y' }}
183
200
# environment: 'Crates.io'
184
201
needs :
185
202
- docs-and-commit
0 commit comments