Skip to content

Commit

Permalink
ci builds
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Dec 20, 2023
1 parent 3811389 commit f6f4577
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 27 deletions.
34 changes: 28 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,35 @@ jobs:
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#test

semver:
msrv:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v3
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
- uses: cachix/install-nix-action@v20
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#msrv

msrv:
matrix:
runs-on: ubuntu-latest
needs: check
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- id: set-matrix
run: echo "matrix=$(nix eval --json ".#matrix.x86_64-linux")" | tee $GITHUB_OUTPUT

build:
runs-on: ubuntu-latest
needs: [check, matrix]
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
Expand All @@ -61,4 +79,8 @@ jobs:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#msrv
- run: nix build .#${{ matrix.target }}
- uses: actions/upload-artifact@v3
with:
name: vbsp-to-gltf-${{ matrix.target }}
path: result/bin/vbsp-to-gltf${{ matrix.artifactSuffix }}
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
release:
types: [created]


jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- id: set-matrix
run: echo "matrix=$(nix eval --json ".#releaseMatrix.x86_64-linux")" | tee $GITHUB_OUTPUT

build:
runs-on: ubuntu-latest
needs: matrix
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#${{ matrix.target }}
- name: Upload binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: result/bin/vbsp-to-gltf${{ matrix.artifactSuffix }}
asset_name: vbsp-to-gltf-${{ matrix.target }}
tag: ${{ github.ref }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Convert Valve BSP files to GLTF files
vbsp-to-gltf input.bsp output.glb
```

Note that this requires TF2 to be installed to get the texture and props referenced in the map.

It should be able to automatically detect the tf2 path or you can overwrite it by setting the `TF_DIR` environment variable.

## Model optimization

The output for the converter isn't particularly optimized, it's strongly recommended to run the output through [gltfpack](https://github.com/zeux/meshoptimizer) before usage.
Expand Down
24 changes: 24 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 51 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.inputs.flake-utils.follows = "utils";
cross-naersk.url = "github:icewind1991/cross-naersk";
cross-naersk.inputs.nixpkgs.follows = "nixpkgs";
cross-naersk.inputs.naersk.follows = "naersk";
};

outputs = {
Expand All @@ -15,6 +18,7 @@
utils,
naersk,
rust-overlay,
cross-naersk,
}:
utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)];
Expand All @@ -29,6 +33,14 @@
toolchain = rust-bin.stable.latest.default;
msrvToolchain = rust-bin.stable."${msrv}".default;

hostTarget = pkgs.hostPlatform.config;
targets = [
"x86_64-unknown-linux-musl"
"x86_64-pc-windows-gnu"
hostTarget
];
releaseTargets = lib.lists.remove hostTarget targets;

naersk' = callPackage naersk {
rustc = toolchain;
cargo = toolchain;
Expand All @@ -37,32 +49,50 @@
rustc = msrvToolchain;
cargo = msrvToolchain;
};
cross-naersk' = pkgs.callPackage cross-naersk {inherit naersk;};

buildMatrix = targets: {
include =
builtins.map (target: {
inherit target;
artifactSuffix = cross-naersk'.execSufficForTarget target;
})
targets;
};

src = sourceByRegex ./. ["Cargo.*" "(src|derive|benches|tests|examples|koth_bagel.*)(/.*)?"];
src = sourceByRegex ./. ["Cargo.*" "(src|derive|benches|tests|examples.*)(/.*)?"];
nearskOpt = {
pname = "vbsp";
pname = "vbsp-to-gltf";
root = src;
};
in rec {
packages = {
check = naersk'.buildPackage (nearskOpt
// {
mode = "check";
});
clippy = naersk'.buildPackage (nearskOpt
// {
mode = "clippy";
});
test = naersk'.buildPackage (nearskOpt
// {
release = false;
mode = "test";
});
msrv = msrvNaersk.buildPackage (nearskOpt
// {
mode = "check";
});
};
packages =
lib.attrsets.genAttrs targets (target:
(cross-naersk'.buildPackage target) nearskOpt)
// rec {
vbsp-to-gltf = packages.${hostTarget};
check = naersk'.buildPackage (nearskOpt
// {
mode = "check";
});
clippy = naersk'.buildPackage (nearskOpt
// {
mode = "clippy";
});
test = naersk'.buildPackage (nearskOpt
// {
release = false;
mode = "test";
});
msrv = msrvNaersk.buildPackage (nearskOpt
// {
mode = "check";
});
default = vbsp-to-gltf;
};

matrix = buildMatrix targets;
releaseMatrix = buildMatrix releaseTargets;

devShells = let
tools = with pkgs; [
Expand Down

0 comments on commit f6f4577

Please sign in to comment.