Skip to content

Create sync upstream.yml #579

Create sync upstream.yml

Create sync upstream.yml #579

Workflow file for this run

name: Build Dalamud
on: [push, pull_request, workflow_dispatch]
# Globally blocking because of git pushes in deploy step
concurrency:
group: build_dalamud_${{ github.repository_owner }}
cancel-in-progress: false
jobs:
build:
name: Build on Windows
permissions:
id-token: write
contents: read
attestations: write
runs-on: windows-2022
steps:
- name: Checkout Dalamud
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Setup MSBuild
uses: microsoft/[email protected]
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '9.0.200'
- name: Define VERSION
run: |
$env:COMMIT = $env:GITHUB_SHA.Substring(0, 7)
$env:REPO_NAME = $env:GITHUB_REPOSITORY -replace '.*/'
$env:BRANCH = $env:GITHUB_REF -replace '.*/'
($env:REPO_NAME) >> VERSION
($env:BRANCH) >> VERSION
($env:COMMIT) >> VERSION
- name: Build and Test Dalamud
run: .\build.ps1 ci
# - name: Sign Dalamud
# if: ${{ github.repository_owner == 'goatcorp' && github.event_name == 'push' }}
# env:
# CODESIGN_CERT_PFX: ${{ secrets.CODESIGN_CERT_PFX }}
# CODESIGN_CERT_PASSWORD: ${{ secrets.CODESIGN_CERT_PASSWORD }}
# run: .\sign.ps1 .\bin\Release
- name: Create hashlist
run: .\CreateHashList.ps1 .\bin\Release
- name: Attest Build
if: ${{ github.repository_owner == 'ottercorp' && github.event_name == 'push' }}
uses: actions/attest-build-provenance@v3
with:
subject-path: |
bin/Release/hashes.json
bin/Release/Dalamud.dll
bin/Release/DalamudCrashHandler.exe
bin/Release/Dalamud.*.dll
bin/Release/Dalamud.*.exe
bin/Release/FFXIVClientStructs.dll
bin/Release/cim*.dll
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dalamud-artifact
path: bin\Release
# check_api_compat:
# name: "Check API Compatibility"
# if: ${{ github.event_name == 'pull_request' }}
# needs: build
# runs-on: windows-latest
# steps:
# - name: "Install .NET SDK"
# uses: actions/setup-dotnet@v3
# with:
# dotnet-version: 7
# - name: "Install ApiCompat"
# run: |
# dotnet tool install -g Microsoft.DotNet.ApiCompat.Tool
# - name: "Download Proposed Artifacts"
# uses: actions/[email protected]
# with:
# name: dalamud-artifact
# path: .\right
# - name: "Download Live (Stg) Artifacts"
# run: |
# Invoke-WebRequest -Uri https://goatcorp.github.io/dalamud-distrib/stg/latest.zip -OutFile latest.zip
# Expand-Archive -Force latest.zip "left"
# - name: "Verify Compatibility"
# run: |
# $FILES_TO_VALIDATE = "Dalamud.dll","FFXIVClientStructs.dll","Lumina.dll","Lumina.Excel.dll"
# $retcode = 0
# foreach ($file in $FILES_TO_VALIDATE) {
# $testout = ""
# Write-Output "::group::=== API COMPATIBILITY CHECK: ${file} ==="
# apicompat -l "left\${file}" -r "right\${file}" --noWarn "CP0006" | Tee-Object -Variable testout
# Write-Output "::endgroup::"
# if ($testout -ne "APICompat ran successfully without finding any breaking changes.") {
# Write-Output "::error::${file} did not pass. Please review it for problems."
# $retcode = 1
# }
# }
# exit $retcode
deploy_stg:
name: Deploy dalamud-distrib staging
if: ${{ github.repository_owner == 'ottercorp' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
needs: build
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
repository: ottercorp/dalamud-distrib
ref: main
ssh-key: ${{ secrets.DEPLOY_SSH }}
- uses: actions/[email protected]
with:
name: dalamud-artifact
path: .\scratch
- uses: geekyeggo/delete-artifact@v5
with:
name: dalamud-artifact
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Generate dalamud-distrib version file
shell: pwsh
env:
GH_BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
Write-Host "Remove useless files"
.\PruneDalamud.ps1
Write-Host "Create hashlist"
$hash = .\CreateHashList.ps1 .\scratch
Write-Host "Create 7z package"
7z a .\canary.7z .\scratch\* -t7z -mf=BCJ2 -mx=9
Compress-Archive -Force .\scratch\* .\canary.zip # Recreate the release zip
$branchName = $env:GH_BRANCH
if ($branchName -eq "master") {
$branchName = "stg"
}
else
{
$branchName = "canary"
}
$newVersion = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\TEMP_gitver.txt")
$revision = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\revision.txt")
$commitHash = [System.IO.File]::ReadAllText("$(Get-Location)\scratch\commit_hash.txt")
Remove-Item -Force -Recurse .\scratch
if (Test-Path -Path $branchName) {
$versionData = Get-Content ".\${branchName}\version" | ConvertFrom-Json
$oldVersion = $versionData.AssemblyVersion
if ($oldVersion -eq $newVersion) {
Remove-Item .\canary.zip
Remove-Item .\canary.7z
} else {
Move-Item -Force ".\canary.zip" ".\${branchName}\latest.zip"
Move-Item -Force ".\canary.7z" ".\${branchName}\latest.7z"
$versionData.AssemblyVersion = $newVersion
$versionData | add-member -Force -Name "GitSha" $commitHash -MemberType NoteProperty
$versionData | add-member -Force -Name "Revision" $revision -MemberType NoteProperty
$versionData | ConvertTo-Json -Compress | Out-File ".\${branchName}\version"
}
echo "DVER=${newVersion}" >> $Env:GITHUB_ENV
} else {
Write-Host "Deployment folder doesn't exist. Not doing anything."
Remove-Item .\canary.zip
Remove-Item .\canary.7z
}
- name: Commit changes
shell: bash
env:
DEPLOY_SSH: ${{ secrets.DEPLOY_SSH }}
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no"
GH_BRANCH: ${{ steps.extract_branch.outputs.branch }}
run: |
eval "$(ssh-agent -s)"
ssh-add - <<< "${DEPLOY_SSH}"
git config --global user.name "Actions User"
git config --global user.email "[email protected]"
git add .
git commit -m "[CI] Update staging for ${DVER} on ${GH_BRANCH}" || true
git push origin main || true
- name: Clear Web Services cache
run: curl -X POST --fail https://aonyx.ffxiv.wang/Dalamud/Release/ClearCache?key=${{ secrets.CACHE_CLEAR_KEY }}