Skip to content

Split release assets per platform and product #80

Split release assets per platform and product

Split release assets per platform and product #80

Workflow file for this run

name: Release
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
UNP4K_VERSION: 4.0.${{ github.run_number }}
jobs:
build:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- rid: win-x64
dnv: net10.0
runner: windows-latest
build_unp4kfs: true
- rid: win-x86
dnv: net10.0
runner: windows-latest
build_unp4kfs: true
- rid: linux-x64
dnv: net10.0
runner: ubuntu-latest
build_unp4kfs: false
publish_args: "--no-self-contained -p:UseAppHost=false -p:PublishSingleFile=false"
- rid: linux-x86
dnv: net10.0
runner: ubuntu-latest
build_unp4kfs: false
publish_args: "--no-self-contained -p:UseAppHost=false -p:PublishSingleFile=false"
- rid: linux-arm64
dnv: net10.0
runner: ubuntu-latest
build_unp4kfs: false
publish_args: "--no-self-contained -p:UseAppHost=false -p:PublishSingleFile=false"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore
run: dotnet restore
- name: Publish ${{ matrix.rid }}
shell: pwsh
run: dotnet publish -c Release -r ${{ matrix.rid }} -f ${{ matrix.dnv }} ${{ matrix.publish_args }}
- name: Remove PDBs and package artifacts (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$rid = "${{ matrix.rid }}"
$dnv = "${{ matrix.dnv }}"
# Publish directories for this RID
$publishDirs = @(
"src\unp4k.fs\bin\Release\$dnv\$rid\publish",
"src\unforge.cli\bin\Release\$dnv\$rid\publish",
"src\unp4k\bin\Release\$dnv\$rid\publish"
)
# Strip PDBs from publish directories
foreach ($dir in $publishDirs) {
if (Test-Path $dir) {
Get-ChildItem -Path $dir -Recurse -Filter *.pdb | Remove-Item -Force
}
}
# Ensure an artifacts directory exists for this RID
$artifactsRoot = "artifacts\$rid"
New-Item -ItemType Directory -Path $artifactsRoot -Force | Out-Null
# Zip each individual publish directory
$map = @{
"unp4k.fs" = "src\unp4k.fs\bin\Release\$dnv\$rid\publish"
"unforge.cli" = "src\unforge.cli\bin\Release\$dnv\$rid\publish"
"unp4k" = "src\unp4k\bin\Release\$dnv\$rid\publish"
}
foreach ($name in $map.Keys) {
$src = $map[$name]
if (Test-Path $src) {
$zipPath = Join-Path $artifactsRoot "$name-$rid-v${{ env.UNP4K_VERSION }}.zip"
if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
Compress-Archive -Path (Join-Path $src '*') -DestinationPath $zipPath
}
}
# Create a "suite" zip that contains all three publish directories
# (kept as subdirectories inside the suite zip, rather than flattened)
$suiteZip = Join-Path $artifactsRoot "suite-$rid-v${{ env.UNP4K_VERSION }}.zip"
if (Test-Path $suiteZip) { Remove-Item $suiteZip -Force }
$pathsToInclude = @()
foreach ($dir in $publishDirs) {
if (Test-Path $dir) {
$pathsToInclude += $dir
}
}
if ($pathsToInclude.Count -gt 0) {
Compress-Archive -Path $pathsToInclude -DestinationPath $suiteZip
}
- name: Remove PDBs and package artifacts (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
rid="${{ matrix.rid }}"
dnv="${{ matrix.dnv }}"
ver="${{ env.UNP4K_VERSION }}"
artifacts_root="artifacts/$rid"
mkdir -p "$artifacts_root"
# Strip PDBs and zip each component
for name in unforge.cli unp4k; do
src="src/$name/bin/Release/$dnv/$rid/publish"
if [ -d "$src" ]; then
find "$src" -name "*.pdb" -delete
zip -j "$artifacts_root/$name-$rid-v$ver.zip" "$src"/*
fi
done
# Create suite zip from all packaged components
suite_dirs=()
for dir in "src/unforge.cli/bin/Release/$dnv/$rid/publish" "src/unp4k/bin/Release/$dnv/$rid/publish"; do
[ -d "$dir" ] && suite_dirs+=("$dir")
done
if [ ${#suite_dirs[@]} -gt 0 ]; then
zip -r "$artifacts_root/suite-$rid-v$ver.zip" "${suite_dirs[@]}"
fi
- name: Upload build artifacts (per RID)
uses: actions/upload-artifact@v4
with:
name: unp4k-${{ matrix.rid }}-v${{ env.UNP4K_VERSION }}
path: artifacts/${{ matrix.rid }}/*.zip
if-no-files-found: error
release:
needs: build
runs-on: ubuntu-latest
if: (github.event_name == 'push')
outputs:
id: ${{ steps.create_release.outputs.id }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Load README
run: |
echo "README<<EOF" >> $GITHUB_ENV
cat README.md >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.UNP4K_VERSION }}
release_name: unp4k Tools for Star Citizen
body: ${{ env.README }}
draft: true
prerelease: false
upload:
needs: release
runs-on: ubuntu-latest
if: (github.event_name == 'push')
strategy:
matrix:
artifact: [unp4k, unp4k-suite, unforge]
rid: [win-x64, win-x86, linux-x64, linux-x86, linux-arm64]
include:
- artifact: unp4k
glob: "unp4k-*-v*.zip"
- artifact: unp4k-suite
glob: "suite-*-v*.zip"
- artifact: unforge
glob: "unforge.cli-*-v*.zip"
steps:
- name: Load Artifacts
uses: actions/download-artifact@v4
with:
name: unp4k-${{ matrix.rid }}-v${{ env.UNP4K_VERSION }}
path: downloaded
- name: Stage Artifact
run: |
file=$(find downloaded -name "${{ matrix.glob }}" | head -1)
cp "$file" ${{ matrix.artifact }}-${{ matrix.rid }}-v${{ env.UNP4K_VERSION }}.zip
- name: Upload Artifact
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ matrix.artifact }}-${{ matrix.rid }}-v${{ env.UNP4K_VERSION }}.zip
asset_name: ${{ matrix.artifact }}-${{ matrix.rid }}-v${{ env.UNP4K_VERSION }}.zip
asset_content_type: application/zip
publish:
needs: [ upload, release ]
runs-on: ubuntu-latest
if: (github.event_name == 'push')
steps:
- name: Publish Release
uses: StuYarrow/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
id: ${{ needs.release.outputs.id }}