Tony's PR #430
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
name: Build | |
on: | |
push: | |
branches: | |
- main | |
- rewrite | |
tags: | |
- v* | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
workflow_dispatch: | |
jobs: | |
build_windows: | |
name: Build (Windows) | |
runs-on: ptlm-runner | |
strategy: | |
matrix: | |
target: [rpkg-cli, rpkg-lib] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup VS environment | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: x64 | |
- name: Generate projects | |
run: | | |
mkdir cmake-build-release | |
cd cmake-build-release | |
cmake -G Ninja ` | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo ` | |
-DCMAKE_CXX_COMPILER=cl ` | |
-DCMAKE_C_COMPILER=cl ` | |
.. | |
- name: Build | |
run: | | |
cmake --build cmake-build-release --target ${{ matrix.target }} | |
- name: Fetch hash lists | |
run: | | |
mkdir _rpkg | |
Invoke-WebRequest -Uri "https://github.com/glacier-modding/Hitman-Hashes/releases/latest/download/latest-hashes.7z" -OutFile "latest-hashes.7z" | |
Invoke-WebRequest -Uri "https://github.com/glacier-modding/Hitman-l10n-Hashes/releases/latest/download/hash_list.hmla" -OutFile "_rpkg/hash_list.hmla" | |
- name: Prepare build | |
run: | | |
7z e latest-hashes.7z -o_rpkg | |
cp cmake-build-release/*.dll _rpkg | |
cp cmake-build-release/*.exe _rpkg | |
cp cmake-build-release/rpkg*.lib _rpkg | |
cp thirdparty/quickentity-ffi/*.dll _rpkg | |
cp thirdparty/assimp/*.dll _rpkg | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.target }} | |
path: _rpkg | |
build_gui: | |
name: "Build GUI" | |
needs: [build_windows] | |
runs-on: ptlm-runner | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup MSBuild | |
uses: microsoft/setup-msbuild@v1.1.3 | |
with: | |
msbuild-architecture: x64 | |
- name: Restore NuGet packages | |
run: cd rpkg-gui && nuget restore rpkg.sln | |
- name: Download rpkg-lib | |
uses: actions/download-artifact@v3 | |
with: | |
name: rpkg-lib | |
path: cmake-build-release | |
- name: Build | |
run: | | |
cd rpkg-gui && msbuild /m /p:Configuration=Release /p:Platform=x64 rpkg.sln | |
- name: Upload GUI artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rpkg-gui | |
path: | | |
_build/Release | |
!_build/Release/*.pdb | |
!_build/Release/rpkg.exe.config | |
!_build/Release/runtimes/ | |
create_release: | |
name: Create release | |
needs: [build_windows, build_gui] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get version | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
# TODO: This action is not maintained - migrate to suitable replacement | |
- name: Create release | |
id: release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.VERSION }} | |
release_name: "RPKG ${{ steps.get_version.outputs.VERSION }}" | |
draft: true | |
prerelease: ${{ contains(github.ref, '-pre') }} | |
outputs: | |
upload_url: ${{ steps.release.outputs.upload_url }} | |
upload_release_asset: | |
name: Upload release asset | |
needs: [create_release] | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
artifact: [ "rpkg-cli", "rpkg-lib", "rpkg-gui" ] | |
steps: | |
- name: Get version | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Format file name | |
id: file_name | |
uses: mad9000/actions-find-and-replace-string@2 | |
with: | |
source: ${{ matrix.artifact }} | |
find: "rpkg" | |
replace: "rpkg_${{ steps.get_version.outputs.VERSION }}" | |
- name: Download artifact | |
uses: actions/download-artifact@v2 | |
with: | |
name: ${{ matrix.artifact }} | |
path: ${{ matrix.artifact }} | |
- name: Package artifact for release | |
run: | | |
cd ${{ matrix.artifact }} | |
zip -r ${{ matrix.artifact }}.zip * | |
- name: Upload release asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.upload_url }} | |
asset_path: ${{ matrix.artifact }}/${{ matrix.artifact }}.zip | |
asset_name: ${{ steps.file_name.outputs.value }}.zip | |
asset_content_type: application/zip | |
trigger_website_build: | |
needs: upload_release_asset | |
runs-on: ubuntu-latest | |
steps: | |
- name: Trigger glaciermodding.org build | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.ACTIONS_KEY }} | |
repository: glacier-modding/glaciermodding.org | |
event-type: build_site |