Skip to content

Commit

Permalink
Merge #865
Browse files Browse the repository at this point in the history
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
bors[bot] and Bromeon committed Feb 21, 2022
2 parents 5f38883 + a7e5b06 commit 9a4c69a
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 58 deletions.
134 changes: 106 additions & 28 deletions .github/workflows/release-version.yml
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,38 @@ The bindings do _**not**_ support in-development Godot 4 versions at the moment.

Detailed setup is explained in [the _Getting Started_ section of the book](https://godot-rust.github.io/book/getting-started.html). In case of problems, consider also reading the [FAQ](https://godot-rust.github.io/book/faq/configuration.html).

### Latest `master` version + Godot 3.4
### Latest released version

This is the recommended way of using godot-rust, if you want to benefit from latest features.
After `bindgen` dependencies are installed, add the `gdnative` crate as a dependency, and set the crate type to `cdylib`:
This is the recommended way of using godot-rust. After `bindgen` dependencies and a current Godot version are installed, add the `gdnative` crate as a dependency, and set the crate type to `cdylib`:

```toml
[dependencies]
gdnative = { git = "https://github.com/godot-rust/godot-rust.git" }
gdnative = "0.10.0-rc.0"

[lib]
crate-type = ["cdylib"]
```

### Godot 3.2.3-stable
### Latest GitHub version

To access the last released version on crates.io, use the following. Note that there have been significant API changes since v0.9.3 -- if you are starting to use godot-rust, we recommend using the `master` version instead.
If you would like to benefit from cutting-edge features and bugfixes, you can use the GitHub version. We have a relatively sophisticated CI and test suite for basic stability, but the GitHub version is typically more experimental and less battle-tested than a `crates.io` release. We also do not guarantee any SemVer compatibility here.

```toml
[dependencies]
gdnative = "0.9.3"
gdnative = { git = "https://github.com/godot-rust/godot-rust.git" }

[lib]
crate-type = ["cdylib"]
```


### Custom builds

To use the bindings with a different Godot version or a custom build of the engine, see [Custom Godot builds](https://godot-rust.github.io/book/advanced-guides/custom-godot.html) in the user guide.

### Async / `yield` support
### Async/yield support

Async support is a work-in-progress, with a low-level API available in the `gdnative-async` crate. This crate is re-exported as `gdnative::tasks`, if the `async` feature is enabled on `gdnative`. See [this page](https://godot-rust.github.io/book/recipes/async-tokio.html) in the book for an introduction to use the async feature with Tokio.
Async support is a work-in-progress, with a low-level API available in `gdnative::tasks`, if the `async` feature is enabled on `gdnative`. See [this page](https://godot-rust.github.io/book/recipes/async-tokio.html) in the book for an introduction to use the async feature with Tokio.

## Example

Expand Down
2 changes: 1 addition & 1 deletion bindings-generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ documentation = "https://docs.rs/crate/gdnative_bindings_generator"
repository = "https://github.com/godot-rust/godot-rust"
homepage = "https://godot-rust.github.io/"
license = "MIT"
version = "0.9.3"
version = "0.10.0-rc.0"
workspace = ".."
edition = "2018"

Expand Down
8 changes: 4 additions & 4 deletions gdnative-async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ description = "Runtime async support for godot-rust."
documentation = "https://docs.rs/crate/gdnative-async"
repository = "https://github.com/godot-rust/godot-rust"
homepage = "https://godot-rust.github.io/"
version = "0.9.3"
version = "0.10.0-rc.0"
license = "MIT"
workspace = ".."
edition = "2018"

[features]

[dependencies]
gdnative-derive = { path = "../gdnative-derive" }
gdnative-core = { path = "../gdnative-core" }
gdnative-bindings = { path = "../gdnative-bindings" }
gdnative-derive = { path = "../gdnative-derive", version = "=0.10.0-rc.0" }
gdnative-core = { path = "../gdnative-core", version = "=0.10.0-rc.0" }
gdnative-bindings = { path = "../gdnative-bindings", version = "=0.10.0-rc.0" }
atomic-waker = "1"
crossbeam-channel = "0.5"
crossbeam-utils = "0.8"
Expand Down
8 changes: 4 additions & 4 deletions gdnative-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "The Godot game engine's automatcally generated bindings to Godot
documentation = "https://docs.rs/crate/gdnative-bindings"
repository = "https://github.com/godot-rust/godot-rust"
homepage = "https://godot-rust.github.io/"
version = "0.9.3"
version = "0.10.0-rc.0"
license = "MIT"
workspace = ".."
edition = "2018"
Expand All @@ -16,10 +16,10 @@ one-class-one-file = []
custom-godot = ["gdnative_bindings_generator/custom-godot"]

[dependencies]
gdnative-sys = { path = "../gdnative-sys" }
gdnative-core = { path = "../gdnative-core" }
gdnative-sys = { path = "../gdnative-sys", version = "=0.10.0-rc.0" }
gdnative-core = { path = "../gdnative-core", version = "=0.10.0-rc.0" }
bitflags = "1"
libc = "0.2"

[build-dependencies]
gdnative_bindings_generator = { path = "../bindings-generator" }
gdnative_bindings_generator = { path = "../bindings-generator", version = "=0.10.0-rc.0" }
8 changes: 4 additions & 4 deletions gdnative-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "The Godot game engine's gdnative core bindings."
documentation = "https://docs.rs/crate/gdnative-core"
repository = "https://github.com/godot-rust/godot-rust"
homepage = "https://godot-rust.github.io/"
version = "0.9.3"
version = "0.10.0-rc.0"
license = "MIT"
workspace = ".."
edition = "2018"
Expand All @@ -16,8 +16,8 @@ gd-test = []
type-tag-fallback = []

[dependencies]
gdnative-sys = { path = "../gdnative-sys" }
gdnative-impl-proc-macros = { path = "../impl/proc-macros" }
gdnative-sys = { path = "../gdnative-sys", version = "=0.10.0-rc.0" }
gdnative-impl-proc-macros = { path = "../impl/proc-macros", version = "=0.10.0-rc.0" }
ahash = "0.7.6"
approx = "0.5"
atomic-take = "1"
Expand All @@ -30,4 +30,4 @@ parking_lot = "0.12"
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
gdnative = { path = "../gdnative" } # for doc-tests
gdnative = { path = "../gdnative", version = "=0.10.0-rc.0" } # for doc-tests
2 changes: 1 addition & 1 deletion gdnative-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "The Godot game engine's gdnative derive and procedural macros."
documentation = "https://docs.rs/crate/gdnative-derive"
repository = "https://github.com/godot-rust/godot-rust"
homepage = "https://godot-rust.github.io/"
version = "0.9.3"
version = "0.10.0-rc.0"
license = "MIT"
workspace = ".."
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion gdnative-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Generated bindings to the Godot game engine's gdnative core types
documentation = "https://docs.rs/crate/gdnative-sys"
repository = "https://github.com/godot-rust/godot-rust"
homepage = "https://godot-rust.github.io/"
version = "0.9.3"
version = "0.10.0-rc.0"
build = "build.rs"
license = "MIT"
workspace = ".."
Expand Down
10 changes: 5 additions & 5 deletions gdnative/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords = ["gamedev", "godot", "engine", "bindings"]
documentation = "https://docs.rs/crate/gdnative"
repository = "https://github.com/godot-rust/godot-rust"
homepage = "https://godot-rust.github.io/"
version = "0.9.3"
version = "0.10.0-rc.0"
license = "MIT"
workspace = ".."
readme = "../README.md"
Expand All @@ -27,10 +27,10 @@ gd-test = ["gdnative-core/gd-test"]
type-tag-fallback = ["gdnative-core/type-tag-fallback"]

[dependencies]
gdnative-derive = { path = "../gdnative-derive" }
gdnative-core = { path = "../gdnative-core" }
gdnative-bindings = { path = "../gdnative-bindings" }
gdnative-async = { path = "../gdnative-async", optional = true }
gdnative-derive = { path = "../gdnative-derive", version = "=0.10.0-rc.0" }
gdnative-core = { path = "../gdnative-core", version = "=0.10.0-rc.0" }
gdnative-bindings = { path = "../gdnative-bindings", version = "=0.10.0-rc.0" }
gdnative-async = { path = "../gdnative-async", version = "=0.10.0-rc.0", optional = true }

[dev-dependencies]
trybuild = "1.0.18" # earrlier versions use broken termcolor 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion impl/proc-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["The godot-rust developers"]
description = "Internal dependency of the gdnative bindings."
repository = "https://github.com/godot-rust/godot-rust"
homepage = "https://godot-rust.github.io/"
version = "0.9.3"
version = "0.10.0-rc.0"
license = "MIT"
workspace = "../.."
edition = "2018"
Expand Down
57 changes: 57 additions & 0 deletions tools/update-version.sh
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"

0 comments on commit 9a4c69a

Please sign in to comment.