ci builds

This commit is contained in:
Robin Appelman 2023-12-21 00:43:12 +01:00
commit f6f4577095
5 changed files with 146 additions and 27 deletions

View file

@ -42,14 +42,6 @@ jobs:
authToken: '${{ secrets.ATTIC_TOKEN }}' authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#test - run: nix build .#test
semver:
runs-on: ubuntu-latest
needs: check
steps:
- uses: actions/checkout@v3
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
msrv: msrv:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: check needs: check
@ -62,3 +54,33 @@ jobs:
instance: https://cache.icewind.me instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}' authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#msrv - run: nix build .#msrv
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 ".#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
- uses: icewind1991/attic-action@v1
with:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- 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
.github/workflows/release.yml vendored Normal file
View file

@ -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 }}

View file

@ -8,6 +8,10 @@ Convert Valve BSP files to GLTF files
vbsp-to-gltf input.bsp output.glb 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 ## 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. 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.

24
flake.lock generated
View file

@ -1,5 +1,28 @@
{ {
"nodes": { "nodes": {
"cross-naersk": {
"inputs": {
"naersk": [
"naersk"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1689107909,
"narHash": "sha256-fb+zxf7AWesECHx1foXOM3NcKHLrdeXzGb6s2AhT6pE=",
"owner": "icewind1991",
"repo": "cross-naersk",
"rev": "51de54599de569e6faa2ee33dd659c5c028d9911",
"type": "github"
},
"original": {
"owner": "icewind1991",
"repo": "cross-naersk",
"type": "github"
}
},
"naersk": { "naersk": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -37,6 +60,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"cross-naersk": "cross-naersk",
"naersk": "naersk", "naersk": "naersk",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay", "rust-overlay": "rust-overlay",

View file

@ -7,6 +7,9 @@
rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.inputs.flake-utils.follows = "utils"; 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 = { outputs = {
@ -15,6 +18,7 @@
utils, utils,
naersk, naersk,
rust-overlay, rust-overlay,
cross-naersk,
}: }:
utils.lib.eachDefaultSystem (system: let utils.lib.eachDefaultSystem (system: let
overlays = [(import rust-overlay)]; overlays = [(import rust-overlay)];
@ -29,6 +33,14 @@
toolchain = rust-bin.stable.latest.default; toolchain = rust-bin.stable.latest.default;
msrvToolchain = rust-bin.stable."${msrv}".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 { naersk' = callPackage naersk {
rustc = toolchain; rustc = toolchain;
cargo = toolchain; cargo = toolchain;
@ -37,32 +49,50 @@
rustc = msrvToolchain; rustc = msrvToolchain;
cargo = msrvToolchain; cargo = msrvToolchain;
}; };
cross-naersk' = pkgs.callPackage cross-naersk {inherit naersk;};
src = sourceByRegex ./. ["Cargo.*" "(src|derive|benches|tests|examples|koth_bagel.*)(/.*)?"]; buildMatrix = targets: {
include =
builtins.map (target: {
inherit target;
artifactSuffix = cross-naersk'.execSufficForTarget target;
})
targets;
};
src = sourceByRegex ./. ["Cargo.*" "(src|derive|benches|tests|examples.*)(/.*)?"];
nearskOpt = { nearskOpt = {
pname = "vbsp"; pname = "vbsp-to-gltf";
root = src; root = src;
}; };
in rec { in rec {
packages = { packages =
check = naersk'.buildPackage (nearskOpt lib.attrsets.genAttrs targets (target:
// { (cross-naersk'.buildPackage target) nearskOpt)
mode = "check"; // rec {
}); vbsp-to-gltf = packages.${hostTarget};
clippy = naersk'.buildPackage (nearskOpt check = naersk'.buildPackage (nearskOpt
// { // {
mode = "clippy"; mode = "check";
}); });
test = naersk'.buildPackage (nearskOpt clippy = naersk'.buildPackage (nearskOpt
// { // {
release = false; mode = "clippy";
mode = "test"; });
}); test = naersk'.buildPackage (nearskOpt
msrv = msrvNaersk.buildPackage (nearskOpt // {
// { release = false;
mode = "check"; mode = "test";
}); });
}; msrv = msrvNaersk.buildPackage (nearskOpt
// {
mode = "check";
});
default = vbsp-to-gltf;
};
matrix = buildMatrix targets;
releaseMatrix = buildMatrix releaseTargets;
devShells = let devShells = let
tools = with pkgs; [ tools = with pkgs; [