Skip to content

Commit

Permalink
workflow run script in base script
Browse files Browse the repository at this point in the history
  • Loading branch information
Grégoire Henry committed Dec 14, 2023
1 parent c7cec78 commit abd9085
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 73 deletions.
77 changes: 4 additions & 73 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,85 +26,16 @@ jobs:
${{ runner.os }}-build-
- name: Set environment
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
echo "PLATFORM=ubuntu" >> "$GITHUB_ENV"
elif [ ${{ matrix.os }} == "macos-latest" ]; then
echo "PLATFORM=macos-x86_64" >> "$GITHUB_ENV"
elif [ ${{ matrix.os }} == "windows-latest" ]; then
echo "PLATFORM=windows" >> "$GITHUB_ENV"
fi
if [ ${{ matrix.os }} == "windows-latest" ]; then
echo "EXT=.exe" >> "$GITHUB_ENV"
echo "OUT_EXT=.exe" >> "$GITHUB_ENV"
else
echo "EXT=" >> "$GITHUB_ENV"
echo "OUT_EXT=.tar.gz" >> "$GITHUB_ENV"
fi
run: ./compile/environment.sh

echo "BUNDLE_NAME=kalast-$GITHUB_REF_NAME-$PLATFORM" >> "$GITHUB_ENV"
echo "RELEASE_FILE=$BUNDLE_NAME$OUT_EXT" >> "$GITHUB_ENV"
echo $PLATFORM
echo $EXT
echo $OUT_EXT
echo $BUNDLE_NAME
echo $RELEASE_FILE
shell: bash

- name: Get SDL2
run: |
if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
sudo apt install -y libsdl2-dev
elif [ ${{ matrix.os }} == "macos-latest" ]; then
brew install SDL2
elif [ ${{ matrix.os }} == "windows-latest" ]; then
cp include/windows/* .
fi
shell: bash
run: ./compile/sdl.sh

- name: Build
run: |
echo "Build main executable."
cargo build -r --all-features && strip target/release/kalast
echo "Build custom executable for specific example."
cargo build -r --all-features --example viewer-picker && strip target/release/examples/viewer-picker
shell: bash
run: ./compile/build.sh

- name: Bundle
run: |
# Make bundle
mkdir -p bundle
cp -r examples bundle
cp target/release/kalast$EXT bundle
cp target/release/examples/viewer-picker$EXT bundle/examples/viewer-picker
cp include/kalast.ico bundle
cp -r include/assets bundle
cp preferences.yaml bundle
cp README.md bundle
if [ ${{ matrix.os }} == "windows-latest" ]; then
cp include/windows/* bundle
fi
cd bundle
cp -r examples/viewer/cfg .
cd ..
mv bundle $BUNDLE_NAME
if [ ${{ matrix.os }} == "windows-latest" ]; then
iscc compile/installer.iss /DVERSION=${{ github.ref_name }} /DSETUP_NAME=${{ env.RELEASE_FILE }} /DBUNDLE_PATH=.\bundle /DASSETS_PATH=.\assets
else
tar cvzf $RELEASE_FILE $BUNDLE_NAME
fi
shell: bash

- name: Check env
run: |
echo "$RELEASE_FILE"
echo "${{ env.RELEASE_FILE }}"
run: ./compile/bundle.sh

- uses: softprops/action-gh-release@v1
with:
Expand Down
7 changes: 7 additions & 0 deletions compile/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

echo "Build main executable."
cargo build -r --all-features && strip target/release/kalast

echo "Build custom executable for specific example."
cargo build -r --all-features --example viewer-picker && strip target/release/examples/viewer-picker
26 changes: 26 additions & 0 deletions compile/bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

mkdir -p bundle
cp -r examples bundle
cp target/release/kalast$EXT bundle
cp target/release/examples/viewer-picker$EXT bundle/examples/viewer-picker
cp include/kalast.ico bundle
cp -r include/assets bundle
cp preferences.yaml bundle
cp README.md bundle

if [ ${{ matrix.os }} == "windows-latest" ]; then
cp include/windows/* bundle
fi

cd bundle
cp -r examples/viewer/cfg .

cd ..
mv bundle $BUNDLE_NAME

if [ ${{ matrix.os }} == "windows-latest" ]; then
iscc compile/installer.iss /DVERSION=${{ github.ref_name }} /DSETUP_NAME=${{ env.RELEASE_FILE }} /DBUNDLE_PATH=.\bundle /DASSETS_PATH=.\assets
else
tar cvzf $RELEASE_FILE $BUNDLE_NAME
fi
26 changes: 26 additions & 0 deletions compile/environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
echo "PLATFORM=ubuntu" >> "$GITHUB_ENV"
elif [ ${{ matrix.os }} == "macos-latest" ]; then
echo "PLATFORM=macos-x86_64" >> "$GITHUB_ENV"
elif [ ${{ matrix.os }} == "windows-latest" ]; then
echo "PLATFORM=windows" >> "$GITHUB_ENV"
fi

if [ ${{ matrix.os }} == "windows-latest" ]; then
echo "EXT=.exe" >> "$GITHUB_ENV"
echo "OUT_EXT=.exe" >> "$GITHUB_ENV"
else
echo "EXT=" >> "$GITHUB_ENV"
echo "OUT_EXT=.tar.gz" >> "$GITHUB_ENV"
fi

echo "BUNDLE_NAME=kalast-$GITHUB_REF_NAME-$PLATFORM" >> "$GITHUB_ENV"
echo "RELEASE_FILE=$BUNDLE_NAME$OUT_EXT" >> "$GITHUB_ENV"

echo $PLATFORM
echo $EXT
echo $OUT_EXT
echo $BUNDLE_NAME
echo $RELEASE_FILE
9 changes: 9 additions & 0 deletions compile/sdl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ ${{ matrix.os }} == "ubuntu-latest" ]; then
sudo apt install -y libsdl2-dev
elif [ ${{ matrix.os }} == "macos-latest" ]; then
brew install SDL2
elif [ ${{ matrix.os }} == "windows-latest" ]; then
cp include/windows/* .
fi

0 comments on commit abd9085

Please sign in to comment.