-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run tests and build binaries on GitHub Actions infrastructure
- Loading branch information
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
name: "test, compile and deploy" | ||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
- run: cargo t --workspace --all-features | ||
|
||
clippy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
- run: cargo c --workspace --all-features | ||
|
||
rustfmt: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
components: rustfmt | ||
- name: Rustfmt Check | ||
uses: actions-rust-lang/rustfmt@v1 | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
needs: test | ||
continue-on-error: true | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- target: aarch64-unknown-linux-gnu | ||
build-essential: crossbuild-essential-arm64 | ||
cargoflags: --config=target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" | ||
cross: true | ||
- target: riscv64gc-unknown-linux-gnu | ||
build-essential: crossbuild-essential-riscv64 | ||
cargoflags: --config=target.riscv64gc-unknown-linux-gnu.linker=\"riscv64-linux-gnu-gcc\" | ||
cross: true | ||
- target: x86_64-unknown-linux-gnu | ||
cross: false | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
target: ${{ matrix.target }} | ||
cache-key: compile-release-${{ matrix.target }} | ||
- if: ${{ matrix.cross }} | ||
run: sudo apt install ${{ matrix.build-essential }} | ||
- run: cargo b --workspace --release --target=${{ matrix.target }} ${{ matrix.cargoflags }} | ||
- run: | | ||
mkdir -p staging/ artifacts/ | ||
cp master/config/default.toml staging/config.toml | ||
find target/${{ matrix.target }}/release -maxdepth 1 -type f -executable -exec cp {} staging/ ';' | ||
pushd staging/ | ||
tar --zstd -cvf ../artifacts/xash3d-master-${{ matrix.target }}.tar.zst * | ||
popd | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: artifact-${{ matrix.target }} | ||
path: artifacts/* | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: ${{ github.event_name == 'push' }} | ||
steps: | ||
- env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
RELEASE_TAG: ${{ github.ref_name == 'master' && 'continuous' || format('continuous-{0}', github.ref_name) }} | ||
run: | | ||
gh release delete "$RELEASE_TAG" \ | ||
--yes \ | ||
--cleanup-tag \ | ||
--repo "$GITHUB_REPOSITORY" || true | ||
sleep 20s | ||
gh run download "$GITHUB_RUN_ID" \ | ||
--dir artifacts/ \ | ||
--repo "$GITHUB_REPOSITORY" | ||
pushd artifacts/ | ||
echo "Found artifacts:" | ||
ls | ||
for i in $(find -mindepth 1 -maxdepth 1 -type d); do | ||
mv "$i"/* . | ||
rm -rf "$i" | ||
done | ||
echo "Repackaged artifacts:" | ||
ls -R | ||
popd | ||
sleep 20s | ||
gh release create "$RELEASE_TAG" artifacts/* \ | ||
--title "xash3d-master Continuous ${{ github.ref_name }} Build" \ | ||
--target $GITHUB_SHA \ | ||
--repo "$GITHUB_REPOSITORY" \ | ||
--prerelease |