mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-01-14 08:47:57 -05:00
127 lines
4.3 KiB
YAML
127 lines
4.3 KiB
YAML
name: Build Executables
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
app_version:
|
|
description: 'Application version'
|
|
type: string
|
|
required: false
|
|
default: ''
|
|
|
|
jobs:
|
|
# Build for each platform in parallel using matrix strategy
|
|
build-platform:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: true
|
|
matrix:
|
|
include:
|
|
- runtime: win-x64
|
|
platform: win-amd64
|
|
- runtime: linux-x64
|
|
platform: linux-amd64
|
|
- runtime: linux-arm64
|
|
platform: linux-arm64
|
|
- runtime: osx-x64
|
|
platform: osx-amd64
|
|
- runtime: osx-arm64
|
|
platform: osx-arm64
|
|
|
|
steps:
|
|
- name: Set variables
|
|
run: |
|
|
ref=${{ github.ref }}
|
|
|
|
# Use input version if provided, otherwise determine from ref
|
|
if [[ -n "${{ inputs.app_version }}" ]]; then
|
|
appVersion="${{ inputs.app_version }}"
|
|
releaseVersion="v$appVersion"
|
|
elif [[ "$ref" =~ ^refs/tags/ ]]; then
|
|
releaseVersion=${ref##refs/tags/}
|
|
appVersion=${releaseVersion#v}
|
|
else
|
|
releaseVersion="dev-$(date +%Y%m%d-%H%M%S)"
|
|
appVersion="0.0.1-dev"
|
|
fi
|
|
|
|
repoFullName=${{ github.repository }}
|
|
repositoryName=${repoFullName#*/}
|
|
|
|
echo "githubRepository=${{ github.repository }}" >> $GITHUB_ENV
|
|
echo "githubRepositoryName=$repositoryName" >> $GITHUB_ENV
|
|
echo "releaseVersion=$releaseVersion" >> $GITHUB_ENV
|
|
echo "appVersion=$appVersion" >> $GITHUB_ENV
|
|
echo "executableName=Cleanuparr.Api" >> $GITHUB_ENV
|
|
|
|
- name: Get vault secrets
|
|
uses: hashicorp/vault-action@v2
|
|
with:
|
|
url: ${{ secrets.VAULT_HOST }}
|
|
method: approle
|
|
roleId: ${{ secrets.VAULT_ROLE_ID }}
|
|
secretId: ${{ secrets.VAULT_SECRET_ID }}
|
|
secrets:
|
|
secrets/data/github repo_readonly_pat | REPO_READONLY_PAT;
|
|
secrets/data/github packages_pat | PACKAGES_PAT
|
|
|
|
- name: Checkout target repository
|
|
uses: actions/checkout@v4
|
|
timeout-minutes: 1
|
|
with:
|
|
repository: ${{ env.githubRepository }}
|
|
ref: ${{ github.ref_name }}
|
|
token: ${{ env.REPO_READONLY_PAT }}
|
|
|
|
- name: Setup dotnet
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: 10.0.x
|
|
|
|
- name: Cache NuGet packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.nuget/packages
|
|
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json', '**/*.csproj') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-nuget-
|
|
|
|
- name: Download frontend artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: frontend-dist
|
|
path: code/frontend/dist/ui/browser
|
|
|
|
- name: Install dependencies and restore
|
|
run: |
|
|
dotnet nuget add source --username ${{ github.repository_owner }} --password ${{ env.PACKAGES_PAT }} --store-password-in-clear-text --name Cleanuparr https://nuget.pkg.github.com/Cleanuparr/index.json
|
|
dotnet restore code/backend/${{ env.executableName }}/${{ env.executableName }}.csproj
|
|
|
|
- name: Copy frontend to backend wwwroot
|
|
run: |
|
|
mkdir -p code/backend/${{ env.executableName }}/wwwroot
|
|
cp -r code/frontend/dist/ui/browser/* code/backend/${{ env.executableName }}/wwwroot/
|
|
|
|
- name: Build ${{ matrix.platform }}
|
|
run: |
|
|
dotnet publish code/backend/${{ env.executableName }}/${{ env.executableName }}.csproj \
|
|
-c Release \
|
|
--runtime ${{ matrix.runtime }} \
|
|
--self-contained \
|
|
-o artifacts/${{ env.githubRepositoryName }}-${{ env.appVersion }}-${{ matrix.platform }} \
|
|
/p:PublishSingleFile=true \
|
|
/p:Version=${{ env.appVersion }} \
|
|
/p:DebugSymbols=false
|
|
|
|
- name: Zip artifact
|
|
run: |
|
|
cd ./artifacts
|
|
zip -r ./${{ env.githubRepositoryName }}-${{ env.appVersion }}-${{ matrix.platform }}.zip ./${{ env.githubRepositoryName }}-${{ env.appVersion }}-${{ matrix.platform }}/
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: executable-${{ matrix.platform }}
|
|
path: ./artifacts/*.zip
|
|
retention-days: 30
|