Skip to content

Publish Anamnesis

Publish Anamnesis #175

name: Publish Anamnesis
permissions:
id-token: write # Required for attestations
attestations: write # Required for attestations
contents: write # Required for creating the draft release
on:
workflow_dispatch:
jobs:
publish:
name: Publish Anamnesis
runs-on: windows-latest
defaults:
run:
shell: pwsh
steps:
# 1. Checkout repo + all submodules
- name: Checkout repository
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
submodules: recursive
persist-credentials: true
# 2. Install .NET SDK
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v3.4.2
with:
dotnet-version: '9.0.x'
# 3. Publish projects
- name: Publish Anamnesis
run: dotnet publish Anamnesis/Anamnesis.csproj /p:PublishProfile=".\Anamnesis\Properties\PublishProfiles\FolderProfile.pubxml" /p:DefineConstants="CI_BUILD"
- name: Publish UpdateExtractor
run: dotnet publish UpdateExtractor/UpdateExtractor.csproj /p:PublishProfile=".\UpdateExtractor\Properties\PublishProfiles\FolderProfile.pubxml" /p:DefineConstants="CI_BUILD"
# 4. Attest Build Artifacts
- name: Generate artifact attestation Ana
uses: actions/attest-build-provenance@v2
with:
subject-path: './publish/Anamnesis.exe'
- name: Generate artifact attestation Updater
uses: actions/attest-build-provenance@v2
with:
subject-path: './publish/Updater/UpdateExtractor.exe'
# 5. Delete redundant files
- name: Delete pdb and xml
run: |
Get-ChildItem -Path './publish/*' -Recurse -Include *.pdb,*.xml -File | Remove-Item -Force
Get-ChildItem -Path './publish/*' -Recurse -Include FASM*,Reloaded.* -File | Remove-Item -Force
# 6. Zip up the entire publish folder
- name: Create ZIP
run: Compress-Archive -Path './publish/*' -DestinationPath './Anamnesis.zip'
# 7. Extract version from VersionInfo.cs
- name: Extract version from application files
run: |
$content = Get-Content ./Anamnesis/VersionInfo.cs -Raw
if ($content -match 'new\s*\(\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)\s*\)') {
$version = "v$($matches[1]).$($matches[2]).$($matches[3]).$($matches[4])"
echo "VERSION_TAG=$version" >> $env:GITHUB_ENV
} else {
Write-Error "Could not extract version from VersionInfo.cs"
exit 1
}
# 8. Check if tag already exists
- name: Check if tag already exists
run: |
git fetch --tags
if (git tag -l "${{ env.VERSION_TAG }}") {
Write-Error "Tag ${{ env.VERSION_TAG }} already exists. Aborting release."
exit 1
}
# 9. Draft a GitHub release
- name: Create draft release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION_TAG }}
name: ${{ env.VERSION_TAG }}
draft: true
artifacts: "Anamnesis.zip"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}