Skip to content

Merge pull request #22 from TheDialgaTeam/dependabot/github_actions/d… #115

Merge pull request #22 from TheDialgaTeam/dependabot/github_actions/d…

Merge pull request #22 from TheDialgaTeam/dependabot/github_actions/d… #115

Workflow file for this run

name: Build and Deploy Xenorig
on:
push:
branches:
- xenorig_future
tags:
- v*
env:
XENORIG_NATIVE_SOURCE_ROOT: "XenoLibNative"
XENORIG_NATIVE_VCPKG_ROOT: "XenoLibNative/vcpkg"
XENORIG_CSPROJ_FILE: "Xenorig/Xenorig.csproj"
XENORIG_PUBLISH_ROOT: "Xenorig/publish"
DOTNET_VERSION: "8.0.x"
VCPKG_NUGET_REPOSITORY: "https://github.com/${{ github.repository }}"
VCPKG_BINARY_SOURCES: clear;nuget,github/${{ github.repository_owner }},readwrite;default,readwrite
defaults:
run:
shell: pwsh
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
build_Xenorig:
name: Build Xenorig (${{ matrix.output_folder }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
arch: [x64, x86, arm, arm64]
exclude:
- os: windows-latest
arch: arm
- os: windows-latest
arch: arm64
- os: ubuntu-latest
arch: x86
- os: macos-latest
arch: x86
- os: macos-latest
arch: arm
- os: macos-latest
arch: arm64
include:
- os: windows-latest
arch: x64
install: ""
output_folder: Xenorig-windows-x64
Xenorig_native:
configure_preset: windows-x64
build_preset: windows-x64
msys2_environment: MINGW64
msys2_install: >-
mingw-w64-x86_64-toolchain
mingw-w64-x86_64-cmake
mingw-w64-x86_64-ninja
Xenorig:
arch: win-x64
- os: windows-latest
arch: x86
install: ""
output_folder: Xenorig-windows-x86
Xenorig_native:
configure_preset: windows-x86
build_preset: windows-x86
msys2_environment: MINGW32
msys2_install: >-
mingw-w64-i686-toolchain
mingw-w64-i686-cmake
mingw-w64-i686-ninja
Xenorig:
arch: win-x86
- os: ubuntu-latest
arch: x64
install: >-
cmake
ninja-build
build-essential
output_folder: Xenorig-linux-x64
Xenorig_native:
configure_preset: linux-x64
build_preset: linux-x64
msys2_environment: ""
msys2_install: ""
Xenorig:
arch: linux-x64
- os: ubuntu-latest
arch: arm
install: >-
cmake
ninja-build
crossbuild-essential-armhf
output_folder: Xenorig-linux-arm
Xenorig_native:
configure_preset: linux-arm
build_preset: linux-arm
msys2_environment: ""
msys2_install: ""
Xenorig:
arch: linux-arm
- os: ubuntu-latest
arch: arm64
install: >-
cmake
ninja-build
crossbuild-essential-arm64
output_folder: Xenorig-linux-arm64
Xenorig_native:
configure_preset: linux-arm64
build_preset: linux-arm64
msys2_environment: ""
msys2_install: ""
Xenorig:
arch: linux-arm64
- os: macos-latest
arch: x64
install: >-
ninja
output_folder: Xenorig-osx-x64
Xenorig_native:
configure_preset: osx-x64
build_preset: osx-x64
msys2_environment: ""
msys2_install: ""
Xenorig:
arch: osx-x64
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Install Program / Dependencies
run: |
if ("${{ runner.os }}" -eq "Windows")
{
if (![string]::IsNullOrWhiteSpace("${{ matrix.install }}"))
{
choco install ${{ matrix.install }} -y
}
}
elseif ("${{ runner.os }}" -eq "Linux")
{
if (![string]::IsNullOrWhiteSpace("${{ matrix.install }}"))
{
sudo apt-get update -y
sudo apt-get install ${{ matrix.install }} -y
}
}
elseif ("${{ runner.os }}" -eq "macOS")
{
if (![string]::IsNullOrWhiteSpace("${{ matrix.install }}"))
{
brew update
brew install ${{ matrix.install }}
}
}
- name: Install dotnet
uses: actions/setup-dotnet@v2
with:
dotnet-version: "${{ env.DOTNET_VERSION }}"
- name: Setup vcpkg
uses: lukka/run-vcpkg@v10
with:
vcpkgDirectory: ${{ github.workspace }}/${{ env.XENORIG_NATIVE_VCPKG_ROOT }}
appendedCacheKey: ${{ matrix.output_folder }}
- name: Setup NuGet Credentials
run: |
dotnet nuget add source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --name "github/${{ github.repository_owner }}" --username "${{ github.actor }}" --password "${{ github.token }}" --store-password-in-clear-text
if ("${{ runner.os }}" -ne 'Windows')
{
$vcpkg_executable = Join-Path "${{ github.workspace }}" "${env:XENORIG_NATIVE_VCPKG_ROOT}" "vcpkg"
$nuget_executable = @(Invoke-Expression "$vcpkg_executable fetch nuget") | Select-Object -Last 1
Invoke-Expression "mono $nuget_executable sources add -source `"https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json`" -name `"github/${{ github.repository_owner }}`" -username `"${{ github.actor }}`" -password `"${{ github.token }}`" -storepasswordincleartext"
}
- name: Setup msys2 environemnt
uses: msys2/setup-msys2@v2
if: runner.os == 'Windows'
with:
update: true
install: ${{ matrix.Xenorig_native.msys2_install }}
msystem: ${{ matrix.Xenorig_native.msys2_environment }}
- name: Build Xenorig Native
working-directory: ${{ github.workspace }}/${{ env.XENORIG_NATIVE_SOURCE_ROOT }}
run: |
if ("${{ runner.os }}" -eq 'Windows')
{
msys2 -c "cmake --preset ${{ matrix.Xenorig_native.configure_preset }}"
msys2 -c "cmake --build --preset ${{ matrix.Xenorig_native.configure_preset }}"
msys2 -c "cmake --install build"
}
else
{
cmake --preset ${{ matrix.Xenorig_native.configure_preset }}
cmake --build --preset ${{ matrix.Xenorig_native.configure_preset }}
cmake --install build
}
- name: Patch Xenorig Version
if: startsWith(github.ref, 'refs/tags/')
run: |
$version = ("${{ github.ref }}" -split "/" | Select-Object -Last 1).Replace('v', '')
$csproj_file = Join-Path "${{ github.workspace }}" "${{ env.XENORIG_CSPROJ_FILE }}"
((Get-Content "$csproj_file") -replace '^(\s*)<Version>.+?<\/Version>(\s*)$', "`$1<Version>$version</Version>`$2") | Set-Content "$csproj_file"
- name: Build Xenorig
run: |
$output = Join-Path "${{ github.workspace }}" "${{ env.XENORIG_PUBLISH_ROOT }}" "${{ matrix.output_folder }}"
$csproj_file = Join-Path "${{ github.workspace }}" "${{ env.XENORIG_CSPROJ_FILE }}"
Invoke-Expression "dotnet publish --runtime ${{ matrix.Xenorig.arch }} -o `"$output`" `"$csproj_file`""
- name: Package Xenorig
run: |
$Xenorig_publish_root = Join-Path "${{ github.workspace }}" "${{ env.XENORIG_PUBLISH_ROOT }}"
Set-Location "$Xenorig_publish_root"
if ("${{ runner.os }}" -eq 'Windows')
{
Invoke-Expression "7z a `"${{ matrix.output_folder }}.zip`" `"${{ matrix.output_folder }}`" -mx=9"
}
else
{
Invoke-Expression "7z a `"${{ matrix.output_folder }}.tar`" `"${{ matrix.output_folder }}`""
Invoke-Expression "7z a `"${{ matrix.output_folder }}.tar.gz`" `"${{ matrix.output_folder }}.tar`" -mx=9"
}
- name: Upload Xenorig artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.output_folder }}
path: |
${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}/*.*
!${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}/*.tar
deploy_Xenorig:
name: Deploy Xenorig
runs-on: ubuntu-latest
needs: [build_Xenorig]
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Create Xenorig artifact directory
run: |
$Xenorig_native_install_root = Join-Path "${{ github.workspace }}" "${{ env.XENORIG_PUBLISH_ROOT }}"
New-Item "$Xenorig_native_install_root" -ItemType 'Directory' -Force
- name: Download Xenorig artifact (windows-x64)
uses: actions/download-artifact@v4.1.7
with:
name: Xenorig-windows-x64
path: ${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}
- name: Download Xenorig artifact (windows-x86)
uses: actions/download-artifact@v4.1.7
with:
name: Xenorig-windows-x86
path: ${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}
- name: Download Xenorig artifact (linux-x64)
uses: actions/download-artifact@v4.1.7
with:
name: Xenorig-linux-x64
path: ${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}
- name: Download Xenorig artifact (linux-arm)
uses: actions/download-artifact@v4.1.7
with:
name: Xenorig-linux-arm
path: ${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}
- name: Download Xenorig artifact (linux-arm64)
uses: actions/download-artifact@v4.1.7
with:
name: Xenorig-linux-arm64
path: ${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}
- name: Download Xenorig artifact (osx-x64)
uses: actions/download-artifact@v4.1.7
with:
name: Xenorig-osx-x64
path: ${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}
- name: Get version number
id: get_version
run: |
$version = "${{ github.ref }}" -split '/' | Select-Object -Last 1
Write-Output "::set-output name=version::$version"
- name: Deploy Xenorig
uses: softprops/action-gh-release@v1
with:
name: Xenorig ${{ steps.get_version.outputs.version }}
body_path: ${{ github.workspace }}/RELEASE_TEMPLATE.md
files: ${{ github.workspace }}/${{ env.XENORIG_PUBLISH_ROOT }}/*
draft: false
fail_on_unmatched_files: true