Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CryZe committed Jan 16, 2021
0 parents commit 92aa4a9
Show file tree
Hide file tree
Showing 14 changed files with 2,711 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/before_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
set -ex

main() {
local tag=$(git tag --points-at HEAD)
local src=$(pwd) \
stage=

if [ "$OS_NAME" = "macOS-latest" ]; then
stage=$(mktemp -d -t tmp)
else
stage=$(mktemp -d)
fi

cp target/$TARGET/release/obs_livesplit_one.dll $stage/obs-livesplit-one.dll 2>/dev/null || :
cp target/$TARGET/release/libobs_livesplit_one.so $stage/libobs_livesplit_one.so 2>/dev/null || :
cp target/$TARGET/release/libobs_livesplit_one.dylib $stage/libobs_livesplit_one.dylib 2>/dev/null || :

cd $stage
if [ "$OS_NAME" = "windows-latest" ]; then
7z a $src/obs-livesplit-one-$tag-$TARGET.zip *
else
tar czf $src/obs-livesplit-one-$tag-$TARGET.tar.gz *
fi
cd $src

rm -rf $stage
}

main
16 changes: 16 additions & 0 deletions .github/workflows/build_shared.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set -ex

main() {
local cargo=cross
if [ "$SKIP_CROSS" = "skip" ]; then
cargo=cargo
fi
local release_flag=""
if [ "$IS_DEPLOY" = "true" ]; then
release_flag="--release"
fi

$cargo build --target $TARGET $release_flag $FEATURES
}

main
111 changes: 111 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Rust

on:
pull_request:
push:
branches:
- 'master'
tags:
- '*'

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
label:
- Windows x86_64
# - Linux x86_64
# - macOS x86_64

include:
- label: Windows x86_64
target: x86_64-pc-windows-msvc
os: windows-latest
cross: skip

# - label: Linux x86_64
# target: x86_64-unknown-linux-gnu
# os: ubuntu-latest
# cross: skip

# - label: macOS x86_64
# target: x86_64-apple-darwin
# os: macOS-latest
# cross: skip

steps:
- name: Checkout Commit
uses: actions/checkout@v2

- name: Install Rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{ matrix.toolchain || 'stable' }}

- name: Install Target
if: matrix.install_target != ''
run: rustup target add ${{ matrix.target }}

- name: Install cross
if: matrix.cross == ''
run: sh .github/workflows/install.sh
env:
OS_NAME: ${{ matrix.os }}

- name: Build Shared Library
if: matrix.dylib == ''
run: sh .github/workflows/build_shared.sh
env:
TARGET: ${{ matrix.target }}
SKIP_CROSS: ${{ matrix.cross }}
IS_DEPLOY: ${{ startsWith(github.ref, 'refs/tags/') && (matrix.release_anyway != '' || !(startsWith(matrix.toolchain, 'nightly') || startsWith(matrix.toolchain, 'beta'))) }}
FEATURES: ${{ matrix.features }}

- name: Prepare Release
if: startsWith(github.ref, 'refs/tags/') && matrix.release == ''
shell: bash
run: .github/workflows/before_deploy.sh
env:
OS_NAME: ${{ matrix.os }}
TARGET: ${{ matrix.target }}

- name: Release
if: startsWith(github.ref, 'refs/tags/') && matrix.release == ''
uses: softprops/action-gh-release@v1
with:
files: obs-livesplit-one-*.*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout Commit
uses: actions/checkout@v2

- name: Install Rust
uses: hecrj/setup-rust-action@v1
with:
components: clippy

- name: Run Clippy
run: cargo clippy --all-features

format:
runs-on: ubuntu-latest
steps:
- name: Checkout Commit
uses: actions/checkout@v2

- name: Install Rust
uses: hecrj/setup-rust-action@v1
with:
components: rustfmt

- name: Run cargo fmt
run: cargo fmt -- --check || true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading

0 comments on commit 92aa4a9

Please sign in to comment.