update action #241
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: Test-And-Build | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
jobs: | |
validate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the source code | |
uses: actions/[email protected] | |
- name: Validate SQF | |
run: python3 Tools/sqf_validator.py | |
- name: Validate Config | |
run: python3 Tools/config_style_checker.py | |
- uses: arma-actions/[email protected] | |
name: Check for BOM | |
lint: | |
runs-on: ubuntu-latest | |
needs: validate | |
steps: | |
- name: Checkout the source code | |
uses: actions/[email protected] | |
- name: Install SQF Lint | |
run: python3 -m pip install git+https://github.com/theace0296/sqf.git | |
- name: Lint (sqflint) | |
run: python Tools/sqflint.py -e 'w' -x 'AIS' -x 'fhqtt' -x 'RandFramework/Alias' -x 'RandFramework/Server/units/fn_zenOccupyHouse.sqf' | |
build: | |
runs-on: windows-latest | |
needs: [validate, lint] | |
steps: | |
- uses: actions/[email protected] | |
- name: Copy mission files to templates | |
run: | | |
$mainFolder = "$($Env:GITHUB_WORKSPACE)" | |
$templateFolder = "$($Env:GITHUB_WORKSPACE)\Mission-Templates" | |
$unwantedFoldersAndFiles = @("mission.sqm", ".vscode", ".github", ".git", ".gitignore", "Mission-Templates", "Pbo-Tools", "Tools") | |
$mainFiles = Get-ChildItem -Path "$mainFolder" | Where-Object { $_.Name -notin $unwantedFoldersAndFiles } | |
$missionFolders = Get-ChildItem -Path "$templateFolder" -Directory | |
if ($missionFolders.Count -gt 0) | |
{ | |
ForEach ($folder in $missionFolders) | |
{ | |
Write-Output "-----------------------------------------------------" | |
Write-Output "Mission Folder: $folder" | |
Write-Output "-----------------------------------------------------" | |
ForEach ($file in $mainFiles) | |
{ | |
Try | |
{ | |
Copy-Item -Path "$($file.Fullname)" -Destination "$folder\$($file.Name)" -Recurse -Force | |
Write-Output " $($file.Name) --> $folder\$($file.Name)" | |
} | |
Catch | |
{ | |
$ErrorMessage = $_ | Out-String | |
Write-Output "The following error occured while copying files for $($file.Name) from Main Mission to Template Mission:" | |
Write-Output $ErrorMessage | |
} | |
} | |
Write-Output "-----------------------------------------------------" | |
} | |
} | |
shell: pwsh | |
- name: Install Mikero Tools | |
run: | | |
$PboTools = "$($Env:GITHUB_WORKSPACE)\Pbo-Tools\" | |
Get-ChildItem "$PboTools" | ForEach-Object { | |
echo "Installing $_" | |
Start-Process -Wait $_.FullName "/S" | |
} | |
echo "Updating environment variables" | |
echo "C:\Program Files (x86)\Mikero\DePboTools\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
shell: pwsh | |
- name: Pack mission files to PBOs | |
run: | | |
Get-Command makepbo | |
$templateFolder = "$($Env:GITHUB_WORKSPACE)\Mission-Templates" | |
$missionFolders = Get-ChildItem -Path "$templateFolder" -Directory | |
New-Item -Path "$($Env:GITHUB_WORKSPACE)\Publish\" -ItemType Directory | |
if ($missionFolders.Count -gt 0) | |
{ | |
ForEach ($folder in $missionFolders) | |
{ | |
Try | |
{ | |
makepbo -P -A -$ -B -X=".bak,.txt" "$folder" | |
Copy-Item -Path "$folder.pbo" -Destination "$($Env:GITHUB_WORKSPACE)\Publish\$($folder.Name).pbo" | |
} | |
Catch | |
{ | |
$ErrorMessage = $_ | Out-String | |
Write-Output "The following error occured while packing $($folder.Name):" | |
Write-Output $ErrorMessage | |
} | |
} | |
} | |
shell: pwsh | |
- name: Upload build artifacts | |
uses: actions/[email protected] | |
with: | |
name: TRGM-Redux-Missions | |
path: ${{ github.workspace }}/Publish/**/* | |
if-no-files-found: error | |
- name: Release Drafter | |
id: release_drafter | |
uses: release-drafter/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Pack Mission Files to Zip | |
run: | | |
Compress-Archive -Path "$($Env:GITHUB_WORKSPACE)\Publish\*.pbo" -DestinationPath "$($Env:GITHUB_WORKSPACE)\Publish\TRGM-Redux-Missions.zip" | |
shell: pwsh | |
- name: Install Node | |
uses: actions/[email protected] | |
with: | |
node-version: '18.x' | |
- name: Install packages | |
run: | | |
Set-Location ${{ github.workspace }}/.github/update-release/ | |
npm ci | |
shell: pwsh | |
- name: Update Release Assets | |
uses: ./.github/update-release/ | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
path: ${{ github.workspace }}/Publish/ | |
prerelease: true | |
release: ${{ steps.release_drafter.outputs.name }} | |
tag: ${{ steps.release_drafter.outputs.tag_name }} | |
body: ${{ steps.release_drafter.outputs.body }} |