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+
16name : " Release workflow"
27
38on :
49 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]+'
1015
1116env :
1217 # Note: used for test and clippy, not for publish
@@ -30,32 +35,37 @@ defaults:
3035jobs :
3136 validation :
3237 runs-on : ubuntu-latest
38+ outputs :
39+ GDEXT_PUBLISHED_VERSION : ${{ steps.interpret-tag-version.outputs.GDEXT_PUBLISHED_VERSION }}
3340 steps :
3441 - uses : actions/checkout@v4
3542
3643 # sed: https://unix.stackexchange.com/a/589584
3744 - name : " Interpret tag version"
45+ id : interpret-tag-version
3846 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
4049 [ -z "$version" ] && {
4150 printf "\n::error::Failed to parse '$GITHUB_REF'.\n"
4251 exit 2
4352 }
4453
4554 echo "Published version: $version"
46- echo "GDEXT_PUBLISHED_VERSION=$version" >> $GITHUB_ENV
55+ echo "GDEXT_PUBLISHED_VERSION=$version" >> $GITHUB_OUTPUT
4756
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 }}"
4958 run : |
5059 echo "Checking crate versions..."
60+ publishedVersion="${{ steps.interpret-tag-version.outputs.GDEXT_PUBLISHED_VERSION }}"
5161
5262 # Check if each Cargo.toml has that version
5363 IFS=' ' read -r -a publishedCrates <<< "$GDEXT_CRATES"
5464 for crate in "${publishedCrates[@]}"; do
5565 readVersion=$(grep -Po '^version = "\K[^"]*' "$crate/Cargo.toml")
5666 printf "* $crate -> $readVersion"
5767
58- if [[ "$readVersion" != "$GDEXT_PUBLISHED_VERSION " ]]; then
68+ if [[ "$readVersion" != "$publishedVersion " ]]; then
5969 printf " ERROR\n"
6070 versionMismatch="1"
6171 else
@@ -128,17 +138,57 @@ jobs:
128138 exit 1
129139 }
130140
131- publish :
141+ docs-and-commit :
132142 runs-on : ubuntu-latest
133- # environment: 'Crates.io'
134143 needs :
144+ - validation
135145 - unit-test
136146 - clippy
137147 - 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 "GodotRust@users.noreply.github.com"
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
138186 steps :
139187 # 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.
140188 # Sleep to leave crates.io and docs.rs some time to index the dependencies, before releasing dependents.
141189 - uses : actions/checkout@v4
190+ with :
191+ ref : releases
142192
143193 - name : " Install Rust (uncached)"
144194 run : rustup update stable
0 commit comments