-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
865: Publishing CI + v0.10.0-rc.0 preparation r=Bromeon a=Bromeon Further automates publishing to crates.io and adds extra validation steps. Adds a local script to replace `Cargo.toml` versions. Prepares for `0.10.0-rc.0` release. bors r+ Co-authored-by: Jan Haller <bromeon@gmail.com>
- Loading branch information
Showing
11 changed files
with
193 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,133 @@ | ||
name: Publish to crates.io | ||
name: "Publish to crates.io" | ||
|
||
on: | ||
push: | ||
branches: | ||
- '!**' | ||
tags: | ||
- '0.9.[0-9]+' | ||
- '0.10.[0-9]+' | ||
- '0.10.[0-9]+-?*' | ||
|
||
env: | ||
GDRUST_FEATURES: "gdnative/async,gdnative/serde" | ||
|
||
# Crates to publish -- important, this doesn't work when there are spaces in any of the paths! | ||
GDRUST_CRATES: > | ||
impl/proc-macros | ||
gdnative-sys | ||
gdnative-derive | ||
gdnative-core | ||
bindings-generator | ||
gdnative-bindings | ||
gdnative-async | ||
gdnative | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
publish: | ||
validation: | ||
runs-on: ubuntu-latest | ||
environment: Deploy | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f | ||
# sed: https://unix.stackexchange.com/a/589584 | ||
- name: "Interpret tag version" | ||
run: | | ||
version=$(echo "$GITHUB_REF" | sed -n "s#refs/tags/\(.*\)#\1#p") | ||
[ -z "$version" ] && { | ||
printf "\nError: Failed to parse '$GITHUB_REF'.\n" | ||
exit 2 | ||
} | ||
echo "Published version: $version" | ||
echo "GDRUST_PUBLISHED_VERSION=$version" >> $GITHUB_ENV | ||
- name: "Verify that Cargo.toml versions match ${{ env.GDRUST_PUBLISHED_VERSION }}" | ||
run: | | ||
echo "Checking crate versions..." | ||
# Check if each Cargo.toml has that version | ||
IFS=' ' read -r -a publishedCrates <<< "$GDRUST_CRATES" | ||
for crate in "${publishedCrates[@]}"; do | ||
readVersion=$(grep -Po '^version = "\K[^"]*' "$crate/Cargo.toml") | ||
printf "* $crate -> $readVersion" | ||
if [[ "$readVersion" != "$GDRUST_PUBLISHED_VERSION" ]]; then | ||
printf " ERROR\n" | ||
versionMismatch="1" | ||
else | ||
printf "\n" | ||
fi | ||
done | ||
if [[ -n "$versionMismatch" ]]; then | ||
printf "\nError: At least one crate has a version mismatching the git tag.\n" | ||
exit 2 | ||
else | ||
printf "\nAll versions OK.\n" | ||
fi | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: validation | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
components: rustfmt, clippy | ||
override: true | ||
- name: "Compile tests" | ||
run: cargo test --workspace --features ${GDRUST_FEATURES} --no-run | ||
- name: "Test" | ||
run: cargo test --workspace --features ${GDRUST_FEATURES} | ||
|
||
- name: "Sanity tests" | ||
run: | | ||
cargo fmt --all -- --check; | ||
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; | ||
cargo test --workspace --features ${GDRUST_FEATURES}; | ||
clippy: | ||
runs-on: ubuntu-latest | ||
needs: validation | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
components: clippy | ||
- name: "Check clippy" | ||
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 | ||
|
||
rustfmt: | ||
runs-on: ubuntu-latest | ||
needs: validation | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
components: rustfmt | ||
- name: "Check rustfmt" | ||
run: cargo fmt --all -- --check | ||
|
||
- name: "Publish to crates.io" | ||
publish: | ||
runs-on: ubuntu-latest | ||
environment: Deploy | ||
needs: [test, clippy, rustfmt] | ||
steps: | ||
# 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. | ||
# Sleep to leave crates.io and docs.rs some time to index the dependencies, before releasing dependents. | ||
- uses: actions/checkout@v2 | ||
- name: "Execute crates.io publishing" | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }} | ||
run: | | ||
(cd impl/proc-macros && cargo publish); | ||
sleep 1m; | ||
(cd gdnative-sys && cargo publish); | ||
sleep 1m; | ||
(cd gdnative-derive && cargo publish); | ||
sleep 1m; | ||
(cd gdnative-core && cargo publish); | ||
sleep 1m; | ||
(cd bindings-generator && cargo publish); | ||
sleep 1m; | ||
(cd gdnative-bindings && cargo publish); | ||
sleep 1m; | ||
(cd gdnative-async && cargo publish); | ||
sleep 1m; | ||
(cd gdnative && cargo publish); | ||
IFS=' ' read -r -a publishedCrates <<< "$GDRUST_CRATES" | ||
for crate in "${publishedCrates[@]}"; do | ||
(cd "$crate" && cargo publish) || { | ||
printf "\nError: Failed to publish $crate\n" | ||
exit 2 | ||
} | ||
sleep 40s | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Small utility to run update crate versions | ||
# Used by godot-rust developers | ||
|
||
# No args specified: do everything | ||
if [ "$#" -eq 0 ]; then | ||
echo "Usage: update-version.sh <newVersion>" | ||
exit 1 | ||
fi | ||
|
||
# --help menu | ||
args=("$@") | ||
for arg in "${args[@]}"; do | ||
if [ "$arg" == "--help" ]; then | ||
echo "Usage: update-version.sh <newVersion>" | ||
echo "" | ||
echo "Replaces currently published version with <newVersion>". | ||
echo "Does not git commit." | ||
exit 0 | ||
fi | ||
done | ||
|
||
# Uncommitted changes, see https://stackoverflow.com/a/3879077 | ||
#if git diff --quiet --exit-code; then | ||
git diff-index --quiet HEAD -- || { | ||
echo "Repo contains uncommitted changes; make sure working tree is clean." | ||
exit 1 | ||
} | ||
|
||
# https://stackoverflow.com/a/11114547 | ||
scriptFile=$(realpath "$0") | ||
scriptPath=$(dirname "$scriptFile") | ||
|
||
newVersion="${args[0]}" | ||
oldVersion=$(grep -Po '^version = "\K[^"]*' "$scriptPath/../gdnative/Cargo.toml") | ||
|
||
publishedCrates=( | ||
"impl/proc-macros" | ||
"gdnative-sys" | ||
"gdnative-derive" | ||
"gdnative-core" | ||
"bindings-generator" | ||
"gdnative-bindings" | ||
"gdnative-async" | ||
"gdnative" | ||
) | ||
|
||
for crate in "${publishedCrates[@]}"; do | ||
# Don't just replace version string itself -- the following only replaces the crate's own version | ||
# (with 'version = "1.2.3"') and dependencies with "=1.2.3", which makes false positives unlikely | ||
sed -i "s!version = \"${oldVersion}\"!version = \"${newVersion}\"!g" "$scriptPath/../$crate/Cargo.toml" || exit 2 | ||
sed -i "s!\"=${oldVersion}\"!\"=${newVersion}\"!g" "$scriptPath/../$crate/Cargo.toml" || exit 2 | ||
done | ||
|
||
git commit -am "Update godot-rust version: $oldVersion -> $newVersion" || exit 2 | ||
git tag "$newVersion" || exit 2 | ||
|
||
echo "Updated version $oldVersion -> $newVersion" |