Skip to content

Holdfast

Holdfast #4

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
upload_to_nexus:
description: "Upload to Nexus Mods (requires NEXUSMODS_API_KEY secret and NEXUSMODS_FILE_GROUP_ID variable)"
type: boolean
default: false
version:
description: "Version without 'v' prefix (e.g. 1.0.0). Required when upload_to_nexus is true; unused otherwise (workflow does nothing without upload_to_nexus)"
type: string
required: false
jobs:
release:
if: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && inputs.upload_to_nexus) }}
runs-on: windows-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
- name: Install CMake and Ninja
uses: lukka/get-cmake@latest
- name: Restore vcpkg binary cache
uses: actions/cache@v5
with:
path: C:\vcpkg-cache
key: vcpkg-${{ hashFiles('vcpkg.json', 'cmake/triplets/**', 'cmake/ports/**') }}
restore-keys: vcpkg-
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
vcpkgDirectory: ${{ github.workspace }}/lib/vcpkg
env:
VCPKG_BINARY_SOURCES: "clear;files,C:\\vcpkg-cache,readwrite"
- name: Configure and Build
uses: lukka/run-cmake@v10
with:
configurePreset: release-windows
buildPreset: release-windows
env:
VCPKG_BINARY_SOURCES: "clear;files,C:\\vcpkg-cache,readwrite"
- name: Determine version
id: version
shell: pwsh
env:
GH_EVENT_NAME: ${{ github.event_name }}
GH_REF_NAME: ${{ github.ref_name }}
INPUT_VERSION: ${{ inputs.version }}
run: |
if ($env:GH_EVENT_NAME -eq "push") {
$v = $env:GH_REF_NAME -replace '^v', ''
} else {
$v = $env:INPUT_VERSION
if (-not $v) {
throw "The 'version' input is required when upload_to_nexus is true (e.g. 1.0.0)"
}
}
echo "value=$v" >> $env:GITHUB_OUTPUT
- name: Package
id: package
shell: bash
env:
VERSION: ${{ steps.version.outputs.value }}
run: bash scripts/package.sh --build-dir build/msvc/Release "$VERSION"
- name: Create GitHub Release
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v3
with:
files: |
${{ steps.package.outputs.zip }}
build/msvc/Release/*.pdb
generate_release_notes: true
- name: Upload to Nexus Mods
if: ${{ github.event_name == 'workflow_dispatch' && inputs.upload_to_nexus }}
uses: Nexus-Mods/upload-action@v1.0.0-beta.5
with:
api_key: ${{ secrets.NEXUSMODS_API_KEY }}
file_group_id: ${{ vars.NEXUSMODS_FILE_GROUP_ID }}
filename: ${{ steps.package.outputs.zip }}
version: ${{ steps.version.outputs.value }}
archive_existing_file: true