diff --git a/.github/scripts/build-example-gba-files.sh b/.github/scripts/build-example-gba-files.sh index c1a79701..beee0401 100755 --- a/.github/scripts/build-example-gba-files.sh +++ b/.github/scripts/build-example-gba-files.sh @@ -17,10 +17,12 @@ function build_rom() { (cd "$GAME_FOLDER" && cargo build --release --verbose --target thumbv4t-none-eabi) + mkdir -p examples/target/examples + arm-none-eabi-objcopy -O binary "$TARGET_FOLDER/thumbv4t-none-eabi/release/$GAME_NAME" "$GBA_FILE" gbafix -p "-t${INTERNAL_NAME:0:12}" "-c${INTERNAL_NAME:0:4}" -mGC "$GBA_FILE" - cp -v "$GBA_FILE" "examples/$GAME_NAME.gba" + cp -v "$GBA_FILE" "examples/target/examples/$GAME_NAME.gba" } mkdir -p examples/target @@ -30,4 +32,4 @@ build_rom "examples/the-hat-chooses-the-wizard" "HATWIZARD" build_rom "book/games/pong" "PONG" -zip examples/target/examples.zip examples/*.gba \ No newline at end of file +(cd examples/target && zip examples.zip examples/*.gba) \ No newline at end of file diff --git a/.github/scripts/publish-crate.sh b/.github/scripts/publish-crate.sh new file mode 100644 index 00000000..4c27c22e --- /dev/null +++ b/.github/scripts/publish-crate.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e # Fail if any command fails + +RELEASE_TAG=$(git tag --points-at HEAD) + +PROJECT=${RELEASE_TAG/\/*/} +(cd "$PROJECT" && cargo publish) diff --git a/.github/scripts/run-branch-build.sh b/.github/scripts/run-branch-build.sh new file mode 100644 index 00000000..45a5a8c4 --- /dev/null +++ b/.github/scripts/run-branch-build.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e # Fail if any command fails + +CARGO_PROJECT_FILES=( agb-*/Cargo.toml agb/Cargo.toml examples/*/Cargo.toml book/games/*/Cargo.toml ) + +for CARGO_PROJECT_FILE in "${CARGO_PROJECT_FILES[@]}"; do + PROJECT_DIR=$(dirname "$CARGO_PROJECT_FILE") + + echo "Checking project $PROJECT_DIR" + (cd "$PROJECT_DIR" && cargo build) + + if echo "$PROJECT_DIR" | grep -qE '^agb'; then + echo "Running clippy on $PROJECT_DIR" + (cd "$PROJECT_DIR" && cargo clippy) + + echo "Testing $PROJECT_DIR in debug mode" + (cd "$PROJECT_DIR" && cargo test) + + echo "Testing $PROJECT_DIR in release mode" + (cd "$PROJECT_DIR" && cargo test --release) + fi +done diff --git a/.github/workflows/build-book.yml b/.github/workflows/build-book.yml new file mode 100644 index 00000000..53acff48 --- /dev/null +++ b/.github/workflows/build-book.yml @@ -0,0 +1,38 @@ +name: Build book + +on: + push: + branches: [ master ] + paths: + 'book/**' + pull_request: + branches: [ master ] + paths: + 'book/**' + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - name: Set CARGO_TARGET_DIR + run: echo "CARGO_TARGET_DIR=$HOME/target" >> $GITHUB_ENV + - name: Install build tools + run: sudo apt-get update && sudo apt-get install build-essential binutils-arm-none-eabi libelf-dev zip -y + - uses: actions/checkout@v2 + - name: Cache + uses: actions/cache@v2.1.7 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + ~/target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Install mdbook + run: cargo install mdbook + - name: Build the book + run: mdbook build + working-directory: book \ No newline at end of file diff --git a/.github/workflows/publish-agb-macros.yml b/.github/workflows/publish-agb-macros.yml deleted file mode 100644 index 53783780..00000000 --- a/.github/workflows/publish-agb-macros.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Publish agb-macros - -on: - push: - tags: - - agb-macros/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@v2 - - name: Login to crates.io - run: cargo login ${{ secrets.CRATE_API }} - - name: Publish agb-macros - run: cargo publish - working-directory: ./agb-macros \ No newline at end of file diff --git a/.github/workflows/publish-agb.yml b/.github/workflows/publish-agb.yml index fe64e7b3..776bae6d 100644 --- a/.github/workflows/publish-agb.yml +++ b/.github/workflows/publish-agb.yml @@ -36,3 +36,14 @@ jobs: asset_name: examples.zip tag: ${{ github.ref }} overwrite: true + + - name: Install mdbook + run: cargo install mdbook + - name: Build the book + run: mdbook build + working-directory: book + - name: Deploy the book + uses: JamesIves/github-pages-deploy-action@v4.2.2 + with: + branch: gh-pages + folder: book/book diff --git a/.github/workflows/publish-image-converter.yml b/.github/workflows/publish-image-converter.yml deleted file mode 100644 index 8dfb3844..00000000 --- a/.github/workflows/publish-image-converter.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Publish agb-image-converter - -on: - push: - tags: - - agb-image-converter/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@v2 - - name: Login to crates.io - run: cargo login ${{ secrets.CRATE_API }} - - name: Publish agb-image-converter - run: cargo publish - working-directory: ./agb-image-converter \ No newline at end of file diff --git a/.github/workflows/publish-sound-converter.yml b/.github/workflows/publish-sound-converter.yml deleted file mode 100644 index 6ac465fa..00000000 --- a/.github/workflows/publish-sound-converter.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Publish agb-sound-converter - -on: - push: - tags: - - agb-sound-converter/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@v2 - - name: Login to crates.io - run: cargo login ${{ secrets.CRATE_API }} - - name: Publish agb-sound-converter - run: cargo publish - working-directory: ./agb-sound-converter \ No newline at end of file diff --git a/.github/workflows/publish-agb-fixnum.yml b/.github/workflows/publish-sub-crate.yml similarity index 71% rename from .github/workflows/publish-agb-fixnum.yml rename to .github/workflows/publish-sub-crate.yml index 3ff76916..13240fed 100644 --- a/.github/workflows/publish-agb-fixnum.yml +++ b/.github/workflows/publish-sub-crate.yml @@ -1,9 +1,9 @@ -name: Publish agb-fixnum +name: Publish sub crate on: push: tags: - - agb-fixnum/v* + - "*/v*" jobs: build: @@ -15,6 +15,5 @@ jobs: uses: actions/checkout@v2 - name: Login to crates.io run: cargo login ${{ secrets.CRATE_API }} - - name: Publish agb-fixnum - run: cargo publish - working-directory: ./agb-fixnum \ No newline at end of file + - name: Publish crate + run: bash .github/scripts/publish-crate.sh diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index aa5c65e1..363ff545 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -31,33 +31,7 @@ jobs: run: cargo install --path mgba-test-runner --verbose - name: Install gbafix run: cargo install gbafix - - name: Build agb library - working-directory: agb - run: cargo build --verbose - - name: Run Clippy on agb - working-directory: agb - run: cargo clippy --verbose - - name: Run Clippy on agb image converter - working-directory: agb-image-converter - run: cargo clippy --verbose - - name: Run Clippy on agb sound converter - working-directory: agb-sound-converter - run: cargo clippy --verbose - - name: Run Clippy on agb macros - working-directory: agb-macros - run: cargo clippy --verbose - - name: Run Clippy on agb fixnum - working-directory: agb-fixnum - run: cargo clippy --verbose - - name: Run Tests for fixnum - working-directory: agb-fixnum - run: cargo test --verbose - - name: Run Tests for agb in debug mode - working-directory: agb - run: cargo test --verbose - - name: Run Tests for agb in release mode - working-directory: agb - run: cargo test --verbose --release + - name: Build and test all crates + run: bash .github/scripts/run-branch-build.sh - name: Build example projects - run: bash .github/scripts/build-example-gba-files.sh - \ No newline at end of file + run: bash .github/scripts/build-example-gba-files.sh \ No newline at end of file diff --git a/examples/.gitignore b/examples/.gitignore deleted file mode 100644 index fdcffe19..00000000 --- a/examples/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.gba \ No newline at end of file diff --git a/release.sh b/release.sh index 9e90d56c..9b9f91b4 100755 --- a/release.sh +++ b/release.sh @@ -31,26 +31,19 @@ case "$PROJECT" in DIRECTORY="agb" TAGNAME="v$VERSION" ;; - agb-image-converter) - DIRECTORY="agb-image-converter" - TAGNAME="agb-image-converter/v$VERSION" - ;; - agb-sound-converter) - DIRECTORY="agb-sound-converter" - TAGNAME="agb-sound-converter/v$VERSION" - ;; - agb-macros) - DIRECTORY="agb-macros" - TAGNAME="agb-macros/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" ;; - agb-fixnum) - DIRECTORY="agb-fixnum" - TAGNAME="agb-fixnum/v$VERSION" - ;; *) echo "Unknown project name $PROJECT" exit 1