From 509e669be6b623e2fca3fb35cfd85b21c0d6836a Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:15:18 -0800 Subject: [PATCH 01/12] ci: Update checkout+upload/download-artifact to v3 --- .github/workflows/ci.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62fd17d3ef..f69e964035 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Lint Commit Messages @@ -31,7 +31,7 @@ jobs: image: openrct2/openrct2-build:4-format steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run clang-format shell: sh run: scripts/check-code-formatting @@ -48,7 +48,7 @@ jobs: PLATFORM: ${{ matrix.platform }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build OpenRCT2 run: . scripts/setenv && build - name: Build artifacts @@ -58,7 +58,7 @@ jobs: build-symbols build-installer -i - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-${{ matrix.platform }} path: artifacts @@ -97,7 +97,7 @@ jobs: build_flags: -DDISABLE_HTTP=Off -DENABLE_SCRIPTING=ON -DCMAKE_CXX_FLAGS="-Wno-error=cast-function-type -Wno-error=unused-function" -DSTATIC=on -DMINGW_TARGET_NT5_1=ON steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -110,7 +110,7 @@ jobs: ninja -k0 - name: Upload artifacts (CI) if: matrix.platform == 'NT5.1' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ matrix.platform }} path: bin/openrct2.exe @@ -136,7 +136,7 @@ jobs: run_tests: false steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -157,7 +157,7 @@ jobs: cd artifacts zip -rqy openrct2-macos.zip OpenRCT2.app - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-${{ matrix.arch }}-cmake path: artifacts/openrct2-macos.zip @@ -168,14 +168,14 @@ jobs: needs: macos-cmake steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: download x64 app bundle - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-x64-cmake path: macos_universal/x64 - name: download arm64 app bundle - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-arm64-cmake path: macos_universal/arm64 @@ -195,7 +195,7 @@ jobs: cd artifacts zip -rqy openrct2-macos.zip OpenRCT2.app - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-universal path: artifacts/openrct2-macos.zip @@ -236,7 +236,7 @@ jobs: build_flags: -DFORCE32=ON -DENABLE_SCRIPTING=OFF -DCMAKE_CXX_FLAGS="-m32 -g -gz" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -248,7 +248,7 @@ jobs: - name: Build artifacts run: . scripts/setenv -q && build-portable artifacts/OpenRCT2-${{ runner.os }}-${{ matrix.distro }}-${{ matrix.platform }}.tar.gz bin/install/usr - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-${{ matrix.distro }}-${{ matrix.platform }} path: artifacts @@ -272,7 +272,7 @@ jobs: image: openrct2/openrct2-build:0.3.1-bionic steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -284,7 +284,7 @@ jobs: - name: Build AppImage run: . scripts/setenv -q && build-appimage - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-AppImage path: artifacts @@ -308,7 +308,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout image - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: OpenRCT2/openrct2-docker - name: Build image @@ -334,7 +334,7 @@ jobs: image: openrct2/openrct2-build:0.3.1-bionic steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -349,7 +349,7 @@ jobs: image: openrct2/openrct2-build:0.3.1-android steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -363,7 +363,7 @@ jobs: mkdir -p artifacts mv src/openrct2-android/app/build/outputs/apk/arm/pr/app-arm-pr.apk artifacts/openrct2-arm.apk - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-Android path: artifacts From f73021a293497a713ba8da26371dcc7f1dd34cc5 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:19:40 -0800 Subject: [PATCH 02/12] ci: Shorten container image to container --- .github/workflows/ci.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f69e964035..2e8f33937c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,7 @@ jobs: check-code-formatting: name: Check code formatting runs-on: ubuntu-latest - container: - image: openrct2/openrct2-build:4-format + container: openrct2/openrct2-build:4-format steps: - name: Checkout uses: actions/checkout@v3 @@ -80,8 +79,7 @@ jobs: name: Windows (${{ matrix.platform_name }}) using mingw runs-on: ubuntu-latest needs: check-code-formatting - container: - image: openrct2/openrct2-build:4-mingw + container: openrct2/openrct2-build:4-mingw strategy: fail-fast: false matrix: @@ -212,8 +210,7 @@ jobs: name: Linux (${{ matrix.platform }}, ${{ matrix.distro }}, portable) runs-on: ubuntu-latest needs: check-code-formatting - container: - image: ${{ matrix.image }} + container: ${{ matrix.image }} strategy: fail-fast: false matrix: @@ -268,8 +265,7 @@ jobs: name: Linux (x64, AppImage) runs-on: ubuntu-latest needs: check-code-formatting - container: - image: openrct2/openrct2-build:0.3.1-bionic + container: openrct2/openrct2-build:0.3.1-bionic steps: - name: Checkout uses: actions/checkout@v3 @@ -330,8 +326,7 @@ jobs: name: Linux (Debug, [http, network, OpenGL] disabled) using clang runs-on: ubuntu-latest needs: check-code-formatting - container: - image: openrct2/openrct2-build:0.3.1-bionic + container: openrct2/openrct2-build:0.3.1-bionic steps: - name: Checkout uses: actions/checkout@v3 @@ -345,8 +340,7 @@ jobs: name: Android runs-on: ubuntu-latest needs: check-code-formatting - container: - image: openrct2/openrct2-build:0.3.1-android + container: openrct2/openrct2-build:0.3.1-android steps: - name: Checkout uses: actions/checkout@v3 From 19c0c07db84dfa4f3b516f02c9ac036e0e3d67a9 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:21:59 -0800 Subject: [PATCH 03/12] ci: Github > GitHub --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e8f33937c..e00f482856 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,7 @@ jobs: - arch: x64 cache_key: macos-x64 # Note: only build/run tests on the native architecture of the CI agent - # Github macos-latest agents are currently all Intel + # GitHub macos-latest agents are currently all Intel build_flags: -DARCH="x86_64" -DWITH_TESTS=on run_tests: true - arch: arm64 From 05783ac8f4b8ecdc299ee898c7e9ae6cd742c5a1 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:23:37 -0800 Subject: [PATCH 04/12] ci: Use default run shell for code format check This is for consistency, and so shell doesn't have to be set for potential future run steps. --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e00f482856..e42e3036f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,11 +28,13 @@ jobs: name: Check code formatting runs-on: ubuntu-latest container: openrct2/openrct2-build:4-format + defaults: + run: + shell: sh steps: - name: Checkout uses: actions/checkout@v3 - name: Run clang-format - shell: sh run: scripts/check-code-formatting windows: name: Windows From 82ee210c29369075758c00293806db336bf1fb00 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:29:45 -0800 Subject: [PATCH 05/12] ci: Ignore files irrelevant to building --- .github/workflows/ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e42e3036f8..7c29c53dd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,21 @@ name: CI -on: [push, pull_request] +on: + push: + paths-ignore: + - '.editorconfig' + - '.gitattributes' + - '.github/*_TEMPLATE/**' + - '.github/workflows/localisation.yml' + - '.gitignore' + - '.vscode/**' + pull_request: + paths-ignore: + - '.editorconfig' + - '.gitattributes' + - '.github/*_TEMPLATE/**' + - '.github/workflows/localisation.yml' + - '.gitignore' + - '.vscode/**' defaults: run: shell: bash From abb2009af48ba1b4a1680a731d4f40f2ae106506 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:33:27 -0800 Subject: [PATCH 06/12] build-appimage-docker.sh: Replace wget with curl This removes an unneeded dependency. --- scripts/linux/build-appimage-docker.sh | 2 +- scripts/linux/build-appimage.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/linux/build-appimage-docker.sh b/scripts/linux/build-appimage-docker.sh index cde760edf4..4f5c3897d9 100755 --- a/scripts/linux/build-appimage-docker.sh +++ b/scripts/linux/build-appimage-docker.sh @@ -5,6 +5,6 @@ REPO_ROOT=$(readlink -f $(dirname "$0")/../..) docker run --rm -it -e NO_CLEANUP=1 -e CI=1 --device /dev/fuse:mrw -v $(readlink -f .):/ws openrct2/openrct2:ubuntu_amd64 bash -exc " cd /ws apt-get update -apt-get install -y wget libcairo2 +apt-get install -y libcairo2 scripts/linux/build-appimage.sh " diff --git a/scripts/linux/build-appimage.sh b/scripts/linux/build-appimage.sh index 6d2b1529c7..3c978a1cdf 100755 --- a/scripts/linux/build-appimage.sh +++ b/scripts/linux/build-appimage.sh @@ -32,7 +32,7 @@ cmake "$REPO_ROOT" -DCMAKE_INSTALL_PREFIX=/usr -G Ninja -DCMAKE_BUILD_TYPE=Relea ninja -k0 DESTDIR=AppDir ninja install -wget https://github.com/TheAssassin/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage +curl -fLO https://github.com/TheAssassin/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage chmod +x linuxdeploy*.AppImage ./linuxdeploy*.AppImage --appimage-extract-and-run --appdir AppDir/ --output appimage From 52212558028ef2ff2651ef25bf5e27049cb6c2c0 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:53:23 -0800 Subject: [PATCH 07/12] ci: Indenting consistency --- .github/workflows/ci.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c29c53dd4..9ab20a58b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,10 +86,10 @@ jobs: run: | . scripts/setenv -q if [[ "$OPENRCT2_PUSH" == "true" ]]; then - upload-build artifacts/openrct2-portable-*.zip "windows-portable-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH - upload-build artifacts/openrct2-installer-*.exe "windows-installer-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH - upload-build artifacts/openrct2-symbols-*.zip "windows-symbols-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH - upload-backtrace-symbols artifacts/openrct2-symbols-*.zip + upload-build artifacts/openrct2-portable-*.zip "windows-portable-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-installer-*.exe "windows-installer-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-symbols-*.zip "windows-symbols-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-backtrace-symbols artifacts/openrct2-symbols-*.zip else echo 'Not going to push build' fi @@ -220,9 +220,9 @@ jobs: run: | . scripts/setenv if [[ "$OPENRCT2_PUSH" == "true" ]]; then - upload-build artifacts/openrct2-macos.zip macos $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-macos.zip macos $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH else - echo 'Not going to push build' + echo 'Not going to push build' fi linux-portable: name: Linux (${{ matrix.platform }}, ${{ matrix.distro }}, portable) @@ -275,9 +275,9 @@ jobs: run: | . scripts/setenv -q if [[ "$OPENRCT2_PUSH" == "true" ]]; then - upload-build artifacts/OpenRCT2-${{ runner.os }}-${{ matrix.distro }}-${{ matrix.platform }}.tar.gz linux-${{ matrix.platform }} $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/OpenRCT2-${{ runner.os }}-${{ matrix.distro }}-${{ matrix.platform }}.tar.gz linux-${{ matrix.platform }} $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH else - echo 'Not going to push build' + echo 'Not going to push build' fi linux-appimage: name: Linux (x64, AppImage) @@ -335,10 +335,10 @@ jobs: OPENRCT2_BRANCH=$(echo "$GITHUB_REF" | sed 's/refs\/heads\///') echo "Current branch is $OPENRCT2_BRANCH" if [ "$OPENRCT2_BRANCH" = 'develop' ]; then - docker login -u "$OPENRCT2_DOCKER_USER" -p "$OPENRCT2_DOCKER_PASS" - docker push openrct2/openrct2-cli:develop + docker login -u "$OPENRCT2_DOCKER_USER" -p "$OPENRCT2_DOCKER_PASS" + docker push openrct2/openrct2-cli:develop else - echo 'Image not pushed' + echo 'Image not pushed' fi linux-clang: name: Linux (Debug, [http, network, OpenGL] disabled) using clang @@ -384,7 +384,7 @@ jobs: run: | . scripts/setenv -q if [[ "$OPENRCT2_PUSH" == "true" ]]; then - upload-build artifacts/openrct2-arm.apk android-arm $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-arm.apk android-arm $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH else - echo 'Not going to push build' + echo 'Not going to push build' fi From e67327dbb14db43c17a5303d74e38c6d436bf543 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:56:33 -0800 Subject: [PATCH 08/12] ci: windows-mingw improvements Use cmake -B instead of mkdir for windows-mingw. Add Windows to artifact name for consistency with other Windows jobs. --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ab20a58b1..f02364c6ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,14 +121,14 @@ jobs: - name: Build OpenRCT2 run: | sudo su - mkdir bin && cd bin - cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Release -DDISABLE_IPO=on -DFORCE32=on ${{ matrix.build_flags }} + cmake -B bin -G Ninja -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Release -DDISABLE_IPO=on -DFORCE32=on ${{ matrix.build_flags }} + cd bin ninja -k0 - name: Upload artifacts (CI) if: matrix.platform == 'NT5.1' uses: actions/upload-artifact@v3 with: - name: OpenRCT2-${{ matrix.platform }} + name: OpenRCT2-Windows-${{ matrix.platform }} path: bin/openrct2.exe if-no-files-found: error macos-cmake: From c5052c05a1005b85148d49a240997d81e5cda238 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 12:58:01 -0800 Subject: [PATCH 09/12] Make check-code-formatting POSIX compatible [[ ]] double bracket conditions and $OSTYPE are both features of Bash. --- scripts/check-code-formatting | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-code-formatting b/scripts/check-code-formatting index 86c2e64b22..1f79900917 100755 --- a/scripts/check-code-formatting +++ b/scripts/check-code-formatting @@ -2,7 +2,7 @@ readlink_bin='readlink' -if [[ "$OSTYPE" == "darwin"* ]]; then +if [ "$(uname)" == "Darwin" ]; then if ! [ -x "$(command -v greadlink)" ]; then echo 'Please install greadlink with Homebrew: brew install coreutils' exit 1 From 67a70b4235255b44184d4ca1f46c199c46bed28b Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 20:56:47 -0800 Subject: [PATCH 10/12] Use -n/-z in if conditions where possible --- scripts/build | 2 +- scripts/build-installer | 2 +- scripts/linux/build-appimage.sh | 4 ++-- scripts/setenv | 2 +- scripts/upload-backtrace-symbols | 2 +- scripts/upload-build | 4 ++-- src/openrct2-android/gradlew | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/build b/scripts/build index 9274410488..01c5b52525 100755 --- a/scripts/build +++ b/scripts/build @@ -10,7 +10,7 @@ cd $basedir if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then # Patch version.h - if [[ "$OPENRCT2_BUILD" != "" ]]; then + if [[ -n "$OPENRCT2_BUILD" ]]; then echo -e "\033[0;36mPatching version.h...\033[0m" fileversion=$OPENRCT2_VERSION.$OPENRCT2_BUILD productversion="$fileversion-${OPENRCT2_SHA1_SHORT}" diff --git a/scripts/build-installer b/scripts/build-installer index 2f2fb5adff..01a6784de3 100755 --- a/scripts/build-installer +++ b/scripts/build-installer @@ -17,7 +17,7 @@ if [[ "$1" == "-i" ]]; then fi basedir="$(readlink -f `dirname $0`/..)" -if [[ "$output" == "" ]]; then +if [[ -z "$output" ]]; then mkdir -p "$basedir/artifacts" output="$basedir/artifacts/openrct2-installer-$CONFIGURATION-$PLATFORM.exe" fi diff --git a/scripts/linux/build-appimage.sh b/scripts/linux/build-appimage.sh index 3c978a1cdf..cf37d7a365 100755 --- a/scripts/linux/build-appimage.sh +++ b/scripts/linux/build-appimage.sh @@ -1,7 +1,7 @@ #!/bin/bash -ex # use RAM disk if possible -if [ "$CI" == "" ] && [ -d /dev/shm ]; then +if [ -z "$CI" ] && [ -d /dev/shm ]; then TEMP_BASE=/dev/shm else TEMP_BASE=/tmp @@ -15,7 +15,7 @@ cleanup () { fi } -if [ "$NO_CLEANUP" == "" ] && trap cleanup EXIT +if [ -z "$NO_CLEANUP" ] && trap cleanup EXIT # store repo root as variable REPO_ROOT=$(readlink -f $(dirname "$0")/../..) diff --git a/scripts/setenv b/scripts/setenv index bfbeb369e6..8ca470d362 100755 --- a/scripts/setenv +++ b/scripts/setenv @@ -34,7 +34,7 @@ else export OPENRCT2_PUSH=true fi fi -if [[ "$OPENRCT2_ORG_TOKEN" == "" ]]; then +if [[ -z "$OPENRCT2_ORG_TOKEN" ]]; then unset OPENRCT2_PUSH fi diff --git a/scripts/upload-backtrace-symbols b/scripts/upload-backtrace-symbols index b4c5afefe7..e437817d1c 100755 --- a/scripts/upload-backtrace-symbols +++ b/scripts/upload-backtrace-symbols @@ -11,7 +11,7 @@ fi path=$1 -if [ "$BACKTRACE_IO_TOKEN" == "" ]; then +if [ -z "$BACKTRACE_IO_TOKEN" ]; then echo -e "\033[0;31mBACKTRACE_IO_TOKEN not set" exit 1 fi diff --git a/scripts/upload-build b/scripts/upload-build index 76e9cf5e3a..251df1a897 100755 --- a/scripts/upload-build +++ b/scripts/upload-build @@ -71,13 +71,13 @@ case "$flavour" in exit 1 esac -if [ "$branch" != "" ]; then +if [ -n "$branch" ]; then versionextra=-$branch-${sha1:0:7} fi filename=OpenRCT2-$version$versionextra-$flavour echo -e "\033[0;36mUploading to openrct2.org as '$filename'..." -if [ "$OPENRCT2_ORG_TOKEN" == "" ]; then +if [ -z "$OPENRCT2_ORG_TOKEN" ]; then echo -e "\033[0;31mOPENRCT2_ORG_TOKEN not set" exit 1 fi diff --git a/src/openrct2-android/gradlew b/src/openrct2-android/gradlew index 9d82f78915..14d3e67fd5 100755 --- a/src/openrct2-android/gradlew +++ b/src/openrct2-android/gradlew @@ -120,7 +120,7 @@ if $cygwin ; then done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then + if [ -n "$GRADLE_CYGPATTERN" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh From 2e8c16e028a74d74962155e7d98dc556032aff96 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Wed, 9 Mar 2022 21:15:32 -0800 Subject: [PATCH 11/12] Change shebang to env Move parameters from shebang back into set. Add set -e to setenv and vstool for consistency. --- scripts/build | 4 +++- scripts/build-appimage | 4 +++- scripts/build-installer | 4 +++- scripts/build-portable | 4 +++- scripts/build-symbols | 4 +++- scripts/check-code-formatting | 4 +++- scripts/create-macos-universal | 4 +++- scripts/get-discord-rpc | 4 +++- scripts/install-nsis | 4 +++- scripts/linux/build-appimage-docker.sh | 4 +++- scripts/linux/build-appimage.sh | 4 +++- scripts/run-testpaint | 4 +++- scripts/run-tests | 4 +++- scripts/setenv | 4 +++- scripts/upload-backtrace-symbols | 4 +++- scripts/upload-build | 4 +++- scripts/vstool | 4 +++- 17 files changed, 51 insertions(+), 17 deletions(-) diff --git a/scripts/build b/scripts/build index 01c5b52525..fed96357ad 100755 --- a/scripts/build +++ b/scripts/build @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # Ensure we are in root directory if [[ $(uname) == "Darwin" ]]; then diff --git a/scripts/build-appimage b/scripts/build-appimage index 0bc94c9a14..3e3b88c207 100755 --- a/scripts/build-appimage +++ b/scripts/build-appimage @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e echo -e "\033[0;36mBuilding AppImage for OpenRCT2...\033[0m" diff --git a/scripts/build-installer b/scripts/build-installer index 01a6784de3..bc18c336b4 100755 --- a/scripts/build-installer +++ b/scripts/build-installer @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$#" -gt 2 || "$1" == "-h" ]]; then echo 'Create a Windows installer for OpenRCT2' diff --git a/scripts/build-portable b/scripts/build-portable index bd4460cfa1..50b85d251e 100755 --- a/scripts/build-portable +++ b/scripts/build-portable @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then # Create a Windows symbols archive for OpenRCT2 diff --git a/scripts/build-symbols b/scripts/build-symbols index 5fede436c6..8525cf83f1 100755 --- a/scripts/build-symbols +++ b/scripts/build-symbols @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # Check 7z or zip is available if [ -x "$(command -v 7z)" ]; then diff --git a/scripts/check-code-formatting b/scripts/check-code-formatting index 1f79900917..823f811a37 100755 --- a/scripts/check-code-formatting +++ b/scripts/check-code-formatting @@ -1,4 +1,6 @@ -#!/bin/sh -e +#!/usr/bin/env sh + +set -e readlink_bin='readlink' diff --git a/scripts/create-macos-universal b/scripts/create-macos-universal index 2b8f94a412..185ccf6ff1 100755 --- a/scripts/create-macos-universal +++ b/scripts/create-macos-universal @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e echo "Creating macOS universal app bundle" # create app skeleton diff --git a/scripts/get-discord-rpc b/scripts/get-discord-rpc index cd785ff567..4e8ea55891 100755 --- a/scripts/get-discord-rpc +++ b/scripts/get-discord-rpc @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ $(uname) == "Linux" ]]; then basedir="$(readlink -f `dirname $0`/..)" diff --git a/scripts/install-nsis b/scripts/install-nsis index a31d6e3d18..0c815cd867 100755 --- a/scripts/install-nsis +++ b/scripts/install-nsis @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$#" -ne 0 && "$#" -ne 2 ]]; then echo 'Install a portable version of NSIS which can build the OpenRCT2 Windows installer.' diff --git a/scripts/linux/build-appimage-docker.sh b/scripts/linux/build-appimage-docker.sh index 4f5c3897d9..87bd3e3df8 100755 --- a/scripts/linux/build-appimage-docker.sh +++ b/scripts/linux/build-appimage-docker.sh @@ -1,4 +1,6 @@ -#!/bin/bash -ex +#!/usr/bin/env bash + +set -ex REPO_ROOT=$(readlink -f $(dirname "$0")/../..) diff --git a/scripts/linux/build-appimage.sh b/scripts/linux/build-appimage.sh index cf37d7a365..5c19b96d23 100755 --- a/scripts/linux/build-appimage.sh +++ b/scripts/linux/build-appimage.sh @@ -1,4 +1,6 @@ -#!/bin/bash -ex +#!/usr/bin/env bash + +set -ex # use RAM disk if possible if [ -z "$CI" ] && [ -d /dev/shm ]; then diff --git a/scripts/run-testpaint b/scripts/run-testpaint index de0968afc3..9f5cc22a88 100755 --- a/scripts/run-testpaint +++ b/scripts/run-testpaint @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # Ensure we are in root directory basedir="$(readlink -f `dirname $0`/..)" diff --git a/scripts/run-tests b/scripts/run-tests index e02f7d926b..ec0bd8adbc 100755 --- a/scripts/run-tests +++ b/scripts/run-tests @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # Ensure we are in root directory if [[ $(uname) == "Darwin" ]]; then diff --git a/scripts/setenv b/scripts/setenv index 8ca470d362..f8b1e86a4d 100755 --- a/scripts/setenv +++ b/scripts/setenv @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -e # This sets up more environment variables using the existing environment # It should be dot sourced into your environment diff --git a/scripts/upload-backtrace-symbols b/scripts/upload-backtrace-symbols index e437817d1c..8022d3a843 100755 --- a/scripts/upload-backtrace-symbols +++ b/scripts/upload-backtrace-symbols @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$#" -ne 1 ]]; then echo 'Upload OpenRCT2 debug symbols to https://backtrace.io.' diff --git a/scripts/upload-build b/scripts/upload-build index 251df1a897..5c0318e16b 100755 --- a/scripts/upload-build +++ b/scripts/upload-build @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$#" -ne 4 && "$#" -ne 5 ]]; then echo 'Upload an OpenRCT2 build to openrct2.org.' diff --git a/scripts/vstool b/scripts/vstool index e96d4cf708..c1d46e7054 100755 --- a/scripts/vstool +++ b/scripts/vstool @@ -1,3 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -e vstool.cmd $@ From 7d1b6b3d9adef8235257931256de5d8f536b2015 Mon Sep 17 00:00:00 2001 From: Margen67 Date: Fri, 11 Mar 2022 03:31:07 -0800 Subject: [PATCH 12/12] Shorten substring expansion --- scripts/setenv | 2 +- scripts/upload-build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/setenv b/scripts/setenv index f8b1e86a4d..bb47c00a9f 100755 --- a/scripts/setenv +++ b/scripts/setenv @@ -42,7 +42,7 @@ fi # Get the short SHA1 export OPENRCT2_SHA1=$GITHUB_SHA -export OPENRCT2_SHA1_SHORT=${OPENRCT2_SHA1:0:7} +export OPENRCT2_SHA1_SHORT=${OPENRCT2_SHA1::7} unset OPENRCT2_VERSION_EXTRA if [[ "$OPENRCT2_TAG" != "true" ]]; then export OPENRCT2_VERSION_EXTRA=$OPENRCT2_BRANCH-$OPENRCT2_SHA1_SHORT diff --git a/scripts/upload-build b/scripts/upload-build index 5c0318e16b..3bfda7edde 100755 --- a/scripts/upload-build +++ b/scripts/upload-build @@ -74,7 +74,7 @@ case "$flavour" in esac if [ -n "$branch" ]; then - versionextra=-$branch-${sha1:0:7} + versionextra=-$branch-${sha1::7} fi filename=OpenRCT2-$version$versionextra-$flavour