diff --git a/.github/scripts/publish-crate.sh b/.github/scripts/publish-crate.sh index 4c27c22e..b599c127 100644 --- a/.github/scripts/publish-crate.sh +++ b/.github/scripts/publish-crate.sh @@ -2,7 +2,11 @@ set -e # Fail if any command fails -RELEASE_TAG=$(git tag --points-at HEAD) +PROJECTS_TO_RELEASE_IN_ORDER="agb-fixnum agb-macros agb-image-converter agb-sound-converter agb" -PROJECT=${RELEASE_TAG/\/*/} -(cd "$PROJECT" && cargo publish) +for PROJECT in $PROJECTS_TO_RELEASE_IN_ORDER; do + pushd "$PROJECT" + echo "Publishing $PROJECT" + cargo publish + popd +done diff --git a/.github/workflows/publish-agb.yml b/.github/workflows/publish-agb.yml index 248a7220..9697eb7e 100644 --- a/.github/workflows/publish-agb.yml +++ b/.github/workflows/publish-agb.yml @@ -18,9 +18,9 @@ jobs: fetch-depth: 0 - name: Login to crates.io run: cargo login ${{ secrets.CRATE_API }} - - name: Publish agb - run: cargo publish - working-directory: ./agb + + - name: Publish crates + run: bash .github/scripts/publish-crate.sh - name: Update template repo env: diff --git a/.github/workflows/publish-sub-crate.yml b/.github/workflows/publish-sub-crate.yml deleted file mode 100644 index d839bb5c..00000000 --- a/.github/workflows/publish-sub-crate.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Publish sub crate - -on: - push: - tags: - - "*/v*" - -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - name: Install build tools - run: sudo apt-get update && sudo apt-get install build-essential binutils-arm-none-eabi -y - - name: Check out repository - uses: actions/checkout@v3 - - name: Login to crates.io - run: cargo login ${{ secrets.CRATE_API }} - - name: Publish crate - run: bash .github/scripts/publish-crate.sh diff --git a/examples/the-purple-night/Cargo.lock b/examples/the-purple-night/Cargo.lock index eb1503ad..0556c620 100644 --- a/examples/the-purple-night/Cargo.lock +++ b/examples/the-purple-night/Cargo.lock @@ -122,9 +122,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bytemuck" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdead85bdec19c194affaeeb670c0e41fe23de31459efd1c174d049269cf02cc" +checksum = "c53dfa917ec274df8ed3c572698f381a24eef2efba9492d797301b72b6db408a" [[package]] name = "byteorder" @@ -171,14 +171,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.23" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39522e96686d38f4bc984b9198e3a0613264abaebaff2c5c918bfa6b6da09af" +checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" dependencies = [ - "cfg-if 1.0.0", "crc32fast", - "libc", - "miniz_oxide 0.5.1", + "miniz_oxide 0.5.3", ] [[package]] @@ -202,9 +200,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if 1.0.0", "libc", @@ -243,9 +241,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.124" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "libflate" @@ -261,9 +259,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.16" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if 1.0.0", ] @@ -279,9 +277,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.5.1" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" dependencies = [ "adler", ] @@ -315,9 +313,9 @@ checksum = "a0f889fb66f7acdf83442c35775764b51fed3c606ab9cee51500dbde2cf528ca" [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -325,9 +323,9 @@ dependencies = [ [[package]] name = "num-iter" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" dependencies = [ "autocfg", "num-integer", @@ -347,18 +345,18 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +checksum = "7709cef83f0c1f58f666e746a08b21e0085f7440fa6a29cc194d68aac97a4225" [[package]] name = "png" @@ -374,18 +372,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.37" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec757218438d5fda206afc041538b2f6d889286160d649a86a24d37e1235afd1" +checksum = "dd96a1e8ed2596c337f8eae5f24924ec83f5ad5ab21ea8e455d3566c69fbcaf7" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.18" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] @@ -404,18 +402,18 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "serde" -version = "1.0.136" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" +checksum = "1578c6245786b9d168c5447eeacfb96856573ca56c9d68fdcf394be134882a47" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.136" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +checksum = "023e9b1467aef8a10fb88f25611870ada9800ef7e22afce356bb0d2387b6f27c" dependencies = [ "proc-macro2", "quote", @@ -430,13 +428,13 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "1.0.91" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b683b2b825c8eef438b77c36a06dc262294da3d5a5813fac20da149241dcd44d" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -457,9 +455,9 @@ dependencies = [ [[package]] name = "tiled" -version = "0.9.5" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9b76189425fed476c9cb0e2a97adb0c6c9d370bf69a57cb951814e77a5fe63" +checksum = "8d2c30aeea9d8159cb461a17dba23ad28980a2a9c217a6784a14e931e4979d6f" dependencies = [ "base64", "libflate", @@ -477,15 +475,15 @@ dependencies = [ [[package]] name = "ttf-parser" -version = "0.15.0" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c74c96594835e10fa545e2a51e8709f30b173a092bfd6036ef2cec53376244f3" +checksum = "7b3e06c9b9d80ed6b745c7159c40b311ad2916abb34a49e9be2653b90db0d8dd" [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-ident" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" [[package]] name = "version_check" @@ -495,9 +493,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "xml-rs" diff --git a/examples/the-purple-night/Cargo.toml b/examples/the-purple-night/Cargo.toml index ba450953..d635b5db 100644 --- a/examples/the-purple-night/Cargo.toml +++ b/examples/the-purple-night/Cargo.toml @@ -12,7 +12,7 @@ generational-arena = { version = "0.2", default-features = false } [build-dependencies] quote = "1.0.10" -tiled = { version = "0.9.5", default-features = false } +tiled = { version = "0.9.4", default-features = false } [profile.dev] opt-level = 2 diff --git a/release.sh b/release.sh index 14941a64..8a1fe6c5 100755 --- a/release.sh +++ b/release.sh @@ -3,13 +3,12 @@ # Fail if any command fails set -e -PROJECT=$1 -VERSION=$2 -NO_COMMIT=$3 +VERSION=$1 +NO_COMMIT=$2 # Sanity check that we actually have a version if [ "$VERSION" = "" ]; then - echo "Usage $0 [--no-commit]" + echo "Usage $0 [--no-commit]" exit 1 fi @@ -25,33 +24,16 @@ if [ ! "$NO_COMMIT" = "" ] && [ ! "$NO_COMMIT" = "--no-commit" ]; then exit 1 fi -# Set up $DIRECTORY and $TAGNAME -case "$PROJECT" in - agb) - DIRECTORY="agb" - TAGNAME="v$VERSION" - ;; - agb-*) - if [ -f "$PROJECT/Cargo.toml" ]; then - DIRECTORY=$PROJECT - TAGNAME="$PROJECT/v$VERSION" - else - echo "Unknown project name $PROJECT" - exit 1 - fi - ;; - mgba-test-runner) - DIRECTORY="mgba-test-runner" - TAGNAME="mgba-test-runner/v$VERSION" - ;; - *) - echo "Unknown project name $PROJECT" - exit 1 - ;; -esac +function maybe_git() { + if [ "$NO_COMMIT" = "--no-commit" ]; then + echo "Would run: git $*" + else + git "$@" + fi +} # Check that no out-standing changes in git -if [ -n "$(git status --porcelain)" ]; then +if [ "$NO_COMMIT" = "" ] && [ -n "$(git status --porcelain)" ]; then echo "Uncommitted changes, please commit first" exit 1 fi @@ -62,52 +44,49 @@ if [ ! "$NO_COMMIT" = "--no-commit" ] && [ "$(git symbolic-ref --short HEAD)" != exit 1 fi -# Update the version in Cargo.toml -sed -i -e "s/^version = \".*\"/version = \"$VERSION\"/" "$DIRECTORY/Cargo.toml" +TAGNAME="v$VERSION" -# Also update the lock file -(cd "$DIRECTORY" && cargo update) -git add "$DIRECTORY/Cargo.toml" "$DIRECTORY/Cargo.lock" || echo "Failed to git add a file, continuing anyway" +for PROJECT_TOML_FILE in agb/Cargo.toml agb-*/Cargo.toml; do + DIRECTORY=$(dirname "$PROJECT_TOML_FILE") -if [ "$PROJECT" = "agb" ]; then - # also update the agb version in the template and the examples - sed -i -e "s/^agb = \".*\"/agb = \"$VERSION\"/" template/Cargo.toml - git add template/Cargo.toml + # Update the version in Cargo.toml + sed -i -e "s/^version = \".*\"/version = \"$VERSION\"/" "$DIRECTORY/Cargo.toml" - for EXAMPLE_TOML_FILE in examples/*/Cargo.toml book/games/*/Cargo.toml; do - EXAMPLE_DIR=$(dirname "$EXAMPLE_TOML_FILE") - sed -E -i -e "/agb =/ s/version = \"[^\"]+\"/version = \"$VERSION\"/" "$EXAMPLE_DIR/Cargo.toml" - (cd "$EXAMPLE_DIR" && cargo update) - git add "$EXAMPLE_DIR"/{Cargo.toml,Cargo.lock} || echo "Failed to git add a file, continuing anyway" - done -else - PROJECT_NAME_WITH_UNDERSCORES=$(echo -n "$PROJECT" | tr - _) + # Also update the lock file + (cd "$DIRECTORY" && cargo update) - for CARGO_TOML_FILE in agb-*/Cargo.toml agb/Cargo.toml examples/*/Cargo.toml book/games/*/Cargo.toml; do - sed -i -E -e "s/($PROJECT_NAME_WITH_UNDERSCORES = .*version = \")[^\"]+(\".*)/\1$VERSION\2/" "$CARGO_TOML_FILE" - (cd "$(dirname "$CARGO_TOML_FILE")" && cargo generate-lockfile) + if [ "$DIRECTORY" = "agb" ]; then + # also update the agb version in the template and the examples + sed -i -e "s/^agb = \".*\"/agb = \"$VERSION\"/" template/Cargo.toml - git add "$CARGO_TOML_FILE" "${CARGO_TOML_FILE/.toml/.lock}" || echo "Failed to git add a file, continuing anyway" - done -fi + for EXAMPLE_TOML_FILE in examples/*/Cargo.toml book/games/*/Cargo.toml; do + EXAMPLE_DIR=$(dirname "$EXAMPLE_TOML_FILE") + sed -E -i -e "/agb =/ s/version = \"[^\"]+\"/version = \"$VERSION\"/" "$EXAMPLE_DIR/Cargo.toml" + (cd "$EXAMPLE_DIR" && cargo update) + done + else + PROJECT_NAME_WITH_UNDERSCORES=$(echo -n "$DIRECTORY" | tr - _) + + for CARGO_TOML_FILE in agb-*/Cargo.toml agb/Cargo.toml examples/*/Cargo.toml book/games/*/Cargo.toml; do + sed -i -E -e "s/($PROJECT_NAME_WITH_UNDERSCORES = .*version = \")[^\"]+(\".*)/\1$VERSION\2/" "$CARGO_TOML_FILE" + (cd "$(dirname "$CARGO_TOML_FILE")" && cargo generate-lockfile) + done + fi +done # Sanity check to make sure the build works -for CARGO_TOML_FILE in agb-*/Cargo.toml agb/Cargo.toml; do - (cd "$(dirname "$CARGO_TOML_FILE")" && cargo test) -done +just ci for EXAMPLE_TOML_FILE in examples/*/Cargo.toml book/games/*/Cargo.toml; do EXAMPLE_DIR=$(dirname "$EXAMPLE_TOML_FILE") (cd "$EXAMPLE_DIR" && cargo check --release) done -if [ ! "$NO_COMMIT" = "--no-commit" ]; then - # Commit the Cargo.toml changes - git commit -m "Release $PROJECT v$VERSION" +# Commit the Cargo.toml changes +maybe_git commit -am "Release v$VERSION" - # Tag the version - git tag -a "$TAGNAME" -m "$PROJECT - v$VERSION" +# Tag the version +maybe_git tag -a "$TAGNAME" -m "v$VERSION" - echo "Done! Push with" - echo "git push --atomic origin master $TAGNAME" -fi \ No newline at end of file +echo "Done! Push with" +echo "git push --atomic origin master $TAGNAME"