Skip to content

Commit

Permalink
Merge pull request #34 from danieldickison/build
Browse files Browse the repository at this point in the history
Build via GH Actions
  • Loading branch information
danieldickison authored Sep 28, 2024
2 parents f0b3194 + 0bbb042 commit 096564d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 28 deletions.
43 changes: 28 additions & 15 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
name: Rust build, test and clippy
name: Rust Build

on:
push:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3.5.2

- uses: actions/checkout@v4
- name: Cache rust target files
uses: actions/cache@v3.3.1
uses: actions/cache@v4
with:
path: target
key: ${{ runner.os }}-rust-target

- run: sudo npm install -g sass

- name: Check
run: cargo check --verbose --all-targets --locked
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
save-always: true
- name: Install sass
run: sudo npm install -g sass
- name: Run tests
run: cargo test --verbose
run: cargo test --verbose --all-targets --locked
- name: Clippy
run: cargo clippy --verbose --no-deps --all-targets --locked
- name: Build
run: cargo build --bin=server --release --locked --verbose
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: build-output
path: |
target/release/server
public/
if-no-files-found: error
46 changes: 33 additions & 13 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,35 @@ PUBLIC=$KC_HOME/public
SERVER=$KC_HOME/server
SERVICE=kachiclash

case $1 in
--beta)
PUBLIC=$KC_HOME/public-beta
SERVER=$KC_HOME/server-beta
SERVICE=kachiclash-beta
;;
'') ;;
*)
echo "Unknown option: $1"
exit 3
;;
esac
while [[ $# -gt 0 ]]; do
case $1 in
--beta)
shift
PUBLIC=$KC_HOME/public-beta
SERVER=$KC_HOME/server-beta
SERVICE=kachiclash-beta
;;
-r|--run)
GH_RUN_ID="$2"
shift
shift
;;
*)
echo "Unknown option: $1"
exit 3
;;
esac
done

cargo build --bin=server --release --locked || exit
if [ -n "$GH_RUN_ID" ]; then
echo "Using artifact from GH Action run ID: $GH_RUN_ID"
mkdir -p var
gh run download $GH_RUN_ID --name build-output --dir var/build-output
cd var/build-output
else
echo "Building locally"
cargo build --bin=server --release --locked
fi

sudo rsync -rv public/ $PUBLIC
sudo chown -R kachiclash:nogroup $PUBLIC
Expand All @@ -32,3 +47,8 @@ sudo install -vb \
$SERVER

sudo systemctl restart $SERVICE

if [ -n "$GH_RUN_ID" ]; then
cd ..
rm -rf build-output
fi

0 comments on commit 096564d

Please sign in to comment.