Skip to content

Commit

Permalink
Fix CI release build
Browse files Browse the repository at this point in the history
This was definitely done first try in one commit
  • Loading branch information
DomWilliams0 committed Dec 26, 2021
1 parent 97566f7 commit 87d3cdd
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 31 deletions.
59 changes: 48 additions & 11 deletions .build/build-release.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,55 @@
#!/bin/bash
set -e
set -ex

# nested so the next step can zip up name-needed/name-needed non-recursively and end up with a nice name-needed/$FILES structure
DIR=name-needed/name-needed
mkdir -p $DIR
SUFFIX="$1"
PLATFORM="$2"

# ensure suffix is passed if needed e.g. ".exe"
cargo build --release --bin main
mv -v "target/release/main$1" $DIR/name-needed$1
# TODO declare sdl version somewhere else
SDL_VERSION="2.0.14"

# make it executable
if [ -x "$(command -v chmod)" ]; then
chmod +x $DIR/name-needed$1
# declare output first via stdout to actions
if [[ "$PLATFORM" == "linux" ]]; then
TARGET=nn-linux.tar.gz
elif [[ "$PLATFORM" == "windows" ]]; then
TARGET=nn-windows.zip
else
exit 1
fi
echo $TARGET

if [[ "$PLATFORM" == "linux" ]]; then
SDL_FILE="SDL2-$SDL_VERSION"
wget "https://www.libsdl.org/release/$SDL_FILE.zip"
unzip $SDL_FILE.zip

pushd $SDL_FILE
./configure
make -j$(nproc)
sudo make install
popd
elif [[ "$PLATFORM" == "windows" ]]; then
SDL_ZIP="SDL2-devel-$SDL_VERSION-VC.zip"
python .build/download-and-unzip.py "https://www.libsdl.org/release/$SDL_ZIP"

SDL_LIBS="SDL2-$SDL_VERSION/lib/x64"
find $SDL_LIBS -iname '*.lib' -exec cp -v {} "/c/Users/$USERNAME/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/x86_64-pc-windows-msvc/lib" \;
find $SDL_LIBS -iname '*.dll' -exec cp -v {} ./renderer/engine/ \;
fi

DIR=name-needed
mkdir -p $DIR

cargo build --release --bin main
mv -v "target/release/main$SUFFIX" $DIR/name-needed$SUFFIX

mv -v README.md LICENSE resources $DIR
rm -f $DIR/resources/ci_test.ron
rm -f $DIR/resources/ci_test.ron

# package up
if [[ "$PLATFORM" == "linux" ]]; then
tar czf $TARGET name-needed
elif [[ "$PLATFORM" == "windows" ]]; then
find ./renderer/engine -iname '*.dll' -exec cp -v {} name-needed \;

7z a $TARGET name-needed
fi
6 changes: 6 additions & 0 deletions .build/download-and-unzip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import urllib.request, zipfile, sys
resp = urllib.request.urlopen(sys.argv[1])
with open("sdl-devel.zip", "wb") as f:
f.write(resp.read())
with zipfile.ZipFile("sdl-devel.zip") as z:
z.extractall(path=".")
27 changes: 14 additions & 13 deletions .github/workflows/build-test-prealpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ jobs:
if: needs.build_and_test.result != 'failure' && !contains(github.event.head_commit.message, 'skip-ci-release') && github.ref == 'refs/heads/develop'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # keep testing other platforms if one fails
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
include:
- os: ubuntu-latest
suffix: ""
platform: "linux"
zip_suffix: "tar.gz"
content_type: "application/gzip"
- os: windows-latest
suffix: ".exe"
platform: "windows"
zip_suffix: "zip"
content_type: "application/zip"

steps:
- name: Checkout code
Expand All @@ -74,28 +78,25 @@ jobs:
toolchain: stable
- name: Setup Rust cache
uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true

- name: Build release
id: build-release
run: |
./.build/build-release.sh "${{ matrix.suffix }}"
TARGET=$(./.build/build-release.sh "${{ matrix.suffix }}" "${{ matrix.platform }}")
echo "::set-output name=TARGET::$TARGET"
shell: bash

- name: Package release
uses: papeloto/action-zip@v1
with:
files: name-needed/name-needed
dest: nn-${{ matrix.platform }}.zip
recursive: false

- name: Upload release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: nn-${{ matrix.platform }}.zip
asset_name: nn-pre-alpha-${{ github.run_number}}-${{ matrix.platform }}.zip
asset_content_type: application/zip
asset_path: ${{ steps.build-release.outputs.TARGET }}
asset_name: nn-pre-alpha-${{ github.run_number}}-${{ matrix.platform }}.${{ matrix.zip_suffix }}
asset_content_type: ${{ matrix.content_type }}

create_release:
name: Create pre-alpha release
Expand Down Expand Up @@ -123,4 +124,4 @@ jobs:
See the top of the [README](https://github.com/DomWilliams0/name-needed/blob/develop/README.md) for screenshots of the latest changes. Maybe the commits in this release will be published here eventually.
Thank you for checking out the project!
Thank you for checking out the project!
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# name-needed

![Build Status](https://img.shields.io/github/workflow/status/DomWilliams0/name-needed/Build%20and%20test)
![Build status](https://img.shields.io/github/workflow/status/DomWilliams0/name-needed/Build,%20test,%20release%20pre-alpha?label=build)
[![Devlog](https://img.shields.io/badge/devlog-domwillia.ms-orange)](https://domwillia.ms)
[![Lines](https://tokei.rs/b1/github/DomWilliams0/name-needed)](https://github.com/XAMPPRocky/tokei)
[![Files](https://tokei.rs/b1/github/DomWilliams0/name-needed?category=files)](https://github.com/XAMPPRocky/tokei)
Expand Down Expand Up @@ -44,11 +44,11 @@ A one man effort to produce an **open source**, **intuitive** and **high perform

## Building/downloading

The engine uses SDL2 and OpenGL, and is developed primarily on Linux, although it seems to work fine on Windows too.
The engine uses SDL2 and OpenGL 3.3, and is developed primarily on Linux, although it seems to work fine on Windows too. macOS is not yet supported due to its depreciation of OpenGL.

See the [releases](https://github.com/DomWilliams0/name-needed/releases) page for prebuilt binaries - occasionally the main `develop` branch is built and published there. Simply download, unzip and run the binary in that directory.
See the [releases](https://github.com/DomWilliams0/name-needed/releases) page for prebuilt binaries - occasionally the main `develop` branch is built and published there. Download the archive for your platform, unzip and run the `name-needed` binary in that directory. On Linux, you will need to install SDL2 through your distribution's package manager first.

Otherwise you can build it with `cargo build --release` (debug builds are *really* slow). If you don't have SDL2 installed, the [bundled](https://github.com/Rust-SDL2/rust-sdl2/blob/ed465322d137e207b03403a6f452d176ef9efda0/README.md#bundled-feature) feature of SDL can download and compile it for you (requires a C compiler).
Otherwise you can build it with `cargo build --release` (debug builds are *really* slow). Ensure SDL2 is installed.

I use the latest stable Rust toolchain and the newest fanciest language features, so no promises for a Minimal Supported Rust Version.

Expand Down
4 changes: 3 additions & 1 deletion TODOS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# TODOs (384)
# TODOs (385)
* [.build/build-release.sh](.build/build-release.sh) (1)
* `# TODO declare sdl version somewhere else`
* [.build/run-tests.sh](.build/run-tests.sh) (1)
* `# TODO fix "LNK1189: library limit of 65535 objects exceeded" on windows when building `testing` crate`
* [game/ai/src/decision.rs](game/ai/src/decision.rs) (2)
Expand Down
4 changes: 2 additions & 2 deletions renderer/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ color = { path = "../../shared/color" }

panik = { version = "0.2", default-features = false, features = ["use-parking-lot", "use-slog"] }
gameloop = "0.2"
sdl2 = { version = "0.34", optional = true, features = [] }
sdl2-sys = { version = "=0.34.2", optional = true } # fix windows release build https://github.com/Rust-SDL2/rust-sdl2/issues/1029
sdl2 = { version = "0.34", optional = true }
sdl2-sys = { version = "0.34", optional = true }
gl = { version = "0.14", optional = true }
imgui-sdl2 = { version = "0.14", optional = true }
imgui-opengl-renderer = { version = "0.11", optional = true }
Expand Down

0 comments on commit 87d3cdd

Please sign in to comment.