Skip to content

CI

CI #3

Workflow file for this run

name: CI
permissions:
actions: write
contents: write
on:
push:
paths-ignore:
- '.github/*_TEMPLATE/**'
- '*.md'
pull_request:
paths-ignore:
- '.github/*_TEMPLATE/**'
- '*.md'
workflow_dispatch:
schedule:
- cron: "0 10 1 * *"
jobs:
build:
name: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Cache NuGet
uses: actions/cache@v4
with:
path: ${{ env.NUGET_PACKAGES }}
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj') }}
restore-keys: |
nuget-${{ runner.os }}-
nuget-
- name: Build Library
run: dotnet build -c Release ./ValveResourceFormat/ValveResourceFormat.csproj
- name: Build CLI
run: dotnet build -c Release ./Decompiler/Decompiler.csproj
- name: Build GUI
if: matrix.os == 'windows-latest'
run: dotnet build -c Release ./ValveResourceFormat/ValveResourceFormat.csproj
- name: Run tests
run: dotnet test ./Tests/Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput='./lcov.info' /p:Include="[ValveResourceFormat*]*"
# - name: Check formatting
# if: matrix.os == 'ubuntu-latest'
# run: dotnet format --verify-no-changes
- name: Pack nupkg
run: dotnet pack --configuration Release ValveResourceFormat/ValveResourceFormat.csproj
- name: Publish GUI
if: matrix.os == 'windows-latest'
run: dotnet publish --configuration Release --self-contained --runtime win-x64 GUI/GUI.csproj
- name: Publish Decompiler (Windows x64)
if: matrix.os == 'windows-latest'
run: dotnet publish --configuration Release --self-contained --runtime win-x64 Decompiler/Decompiler.csproj
- name: Publish Decompiler (Linux x64)
if: matrix.os == 'ubuntu-latest'
run: dotnet publish --configuration Release --self-contained --runtime linux-x64 Decompiler/Decompiler.csproj
- name: Publish Decompiler (Linux arm)
if: matrix.os == 'ubuntu-latest'
run: dotnet publish --configuration Release --self-contained --runtime linux-arm Decompiler/Decompiler.csproj
- name: Publish Decompiler (Linux arm64)
if: matrix.os == 'ubuntu-latest'
run: dotnet publish --configuration Release --self-contained --runtime linux-arm64 Decompiler/Decompiler.csproj
- name: Publish Decompiler (macOS x64)
if: matrix.os == 'macos-latest'
run: dotnet publish --configuration Release --self-contained --runtime osx-x64 Decompiler/Decompiler.csproj
- name: Publish Decompiler (macOS arm64)
if: matrix.os == 'macos-latest'
run: dotnet publish --configuration Release --self-contained --runtime osx-arm64 Decompiler/Decompiler.csproj
- name: Upload GUI
uses: actions/upload-artifact@v4
if: matrix.os == 'windows-latest'
with:
name: Source2Viewer
path: GUI/bin/Release/win-x64/publish
- name: Upload nupkg
uses: actions/upload-artifact@v4
if: matrix.os == 'windows-latest'
with:
name: nupkg
path: 'ValveResourceFormat/bin/Release/*.nupkg'
- name: Upload Decompiler (Windows x64)
uses: actions/upload-artifact@v4
if: matrix.os == 'windows-latest'
with:
name: Decompiler-windows-x64
path: Decompiler/bin/Release/win-x64/publish
- name: Upload Decompiler (Linux x64)
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest'
with:
name: Decompiler-linux-x64
path: Decompiler/bin/Release/linux-x64/publish
- name: Upload Decompiler (Linux arm)
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest'
with:
name: Decompiler-linux-arm
path: Decompiler/bin/Release/linux-arm/publish
- name: Upload Decompiler (Linux arm64)
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest'
with:
name: Decompiler-linux-arm64
path: Decompiler/bin/Release/linux-arm64/publish
- name: Upload Decompiler (macOS x64)
uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: Decompiler-macos-x64
path: Decompiler/bin/Release/osx-x64/publish
- name: Upload Decompiler (macOS arm64)
uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
with:
name: Decompiler-macos-arm64
path: Decompiler/bin/Release/osx-arm64/publish
- name: Upload test coverage
uses: codecov/codecov-action@v4
if: github.ref == 'refs/heads/master'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./Tests/lcov.info
fail_ci_if_error: true
verbose: true
release:
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display artifacts folder structure
run: ls -Rl
working-directory: artifacts
- name: Create release files
run: |
mkdir release
chmod +x artifacts/Decompiler-linux-x64/Decompiler
chmod +x artifacts/Decompiler-linux-arm/Decompiler
chmod +x artifacts/Decompiler-linux-arm64/Decompiler
chmod +x artifacts/Decompiler-macos-x64/Decompiler
chmod +x artifacts/Decompiler-macos-arm64/Decompiler
zip -9j release/Decompiler-windows-x64.zip artifacts/Decompiler-windows-x64/*
zip -9j release/Decompiler-linux-x64.zip artifacts/Decompiler-linux-x64/*
zip -9j release/Decompiler-linux-arm.zip artifacts/Decompiler-linux-arm/*
zip -9j release/Decompiler-linux-arm64.zip artifacts/Decompiler-linux-arm64/*
zip -9j release/Decompiler-macos-x64.zip artifacts/Decompiler-macos-x64/*
zip -9j release/Decompiler-macos-arm64.zip artifacts/Decompiler-macos-arm64/*
mv artifacts/Source2Viewer/Source2Viewer.exe release/
mv artifacts/nupkg/*.nupkg release/
- name: Display structure of archived files
run: ls -Rl
working-directory: release
- name: Release
uses: softprops/action-gh-release@v2
with:
draft: true
files: release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to NuGet Gallery
run: find -name '*.nupkg' | xargs -i dotnet nuget push {} --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
working-directory: artifacts/nupkg