Skip to content

Commit

Permalink
Merge pull request #582 from Aragas/simple
Browse files Browse the repository at this point in the history
GitHub Actions Workflow
  • Loading branch information
Washi1337 authored Sep 23, 2024
2 parents 2a9d499 + 5f73481 commit 2fdf836
Show file tree
Hide file tree
Showing 38 changed files with 1,173 additions and 214 deletions.
43 changes: 43 additions & 0 deletions .github/actions/get-dotnet-channel/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Convert Target Framework to Channel
description: |
Convert Target Framework to Channel. A channel is either LTS/STS or a version number.
Use `target_framework` for a single conversion with `channel` as output.
Use `target_framework_array` for a single conversion with `channels_multiline` as output.
inputs:
target_framework:
description: 'The target framework to use'
required: false
target_framework_array:
description: 'The target framework array to use'
required: false

outputs:
channel:
description: 'The converted Channel variable'
value: ${{steps.set_output.outputs.channel}}
channels_multiline:
description: 'The converted Channels multiline variable'
value: ${{steps.set_output.outputs.channels_multiline}}

runs:
using: "composite"
steps:
- name: Set Channels
id: set_output
run: |
$target_framework = "${{inputs.target_framework}}";
if ($target_framework -ne '') {
$channel = $target_framework.Replace('coreapp', '').Replace('net', '');
"channel=$channel" | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
}
$target_frameworks = "${{inputs.target_framework_array}}";
if ($target_frameworks -ne '') {
$EOF = -join (1..15 | ForEach {[char]((48..57)+(65..90)+(97..122) | Get-Random)});
"channels_multiline<<$EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
foreach ($target_framework in ConvertFrom-Json "${{inputs.target_framework_array}}") {
$target_framework.Replace('coreapp', '').Replace('net', '') | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
}
"$EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
}
shell: pwsh
51 changes: 51 additions & 0 deletions .github/actions/get-dotnet-path/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Get .NET Path
description: Get .NET path for the architecture

inputs:
architecture:
description: 'The architecture to use'
required: true

outputs:
path:
description: 'The .NET path for the architecture'
value: ${{ steps.set-path.outputs.path }}

runs:
using: "composite"
steps:
- name: Get Program Files path for x86
if: ${{runner.os == 'Windows' && inputs.architecture == 'x86'}}
uses: ./.github/actions/get-program-files
id: get-program-files-x86
with:
architecture: x86

- name: Get Program Files path for x64
if: ${{runner.os == 'Windows' && (inputs.architecture == 'x86' || inputs.architecture == 'x64')}}
uses: ./.github/actions/get-program-files
id: get-program-files-x64
with:
architecture: x64

- name: Set .NET path for ${{inputs.architecture}}
id: set-path
run: |
if ('${{runner.os == 'Windows'}}' -eq 'true') {
if ('${{inputs.architecture == 'x86'}}' -eq 'true') {
$dotnet = "${{steps.get-program-files-x86.outputs.path}}/dotnet/dotnet.exe";
} else {
$dotnet = "${{steps.get-program-files-x64.outputs.path}}/dotnet/dotnet.exe";
}
} elseif ('${{inputs.image == 'macos-14'}}' -eq 'true') {
if ('${{inputs.architecture == 'x64'}}' -eq 'true') {
$dotnet = "/Users/runner/.dotnet/x64/dotnet";
} else {
$dotnet = "/Users/runner/.dotnet/dotnet";
}
} else {
# Ubuntu only has x64
$dotnet = 'dotnet';
}
"path=$dotnet" | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
shell: pwsh
44 changes: 44 additions & 0 deletions .github/actions/get-mono-path/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Get Mono Path
description: Get Mono path for the architecture

inputs:
architecture:
description: 'The architecture to use'
required: true

outputs:
path:
description: 'The Mono path for the architecture'
value: ${{ steps.set-path.outputs.path }}

runs:
using: "composite"
steps:
- name: Get Program Files path for x86
if: ${{runner.os == 'Windows' && inputs.architecture == 'x86'}}
uses: ./.github/actions/get-program-files
id: get-program-files-x86
with:
architecture: x86

- name: Get Program Files path for x64
if: ${{runner.os == 'Windows' && (inputs.architecture == 'x86' || inputs.architecture == 'x64')}}
uses: ./.github/actions/get-program-files
id: get-program-files-x64
with:
architecture: x64

- name: Set Mono path for ${{inputs.architecture}}
id: set-path
run: |
if ('${{runner.os == 'Windows'}}' -eq 'true') {
if ('${{inputs.architecture == 'x86'}}' -eq 'true') {
$mono = "${{steps.get-program-files-x86.outputs.path}}/Mono/bin/mono.exe";
} else {
$mono = "${{steps.get-program-files-x64.outputs.path}}/Mono/bin/mono.exe";
}
} else {
$mono = 'mono';
}
"path=$mono" | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
shell: pwsh
28 changes: 28 additions & 0 deletions .github/actions/get-program-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Get ProgramFiles Path
description: Get ProgramFiles path for the architecture

inputs:
architecture:
description: 'The architecture to use'
required: true

outputs:
path:
description: 'The ProgramFiles path for the architecture'
value: ${{ steps.set-path.outputs.path }}

runs:
using: "composite"
steps:
- name: Set Program Files path for ${{inputs.architecture}}
id: set-path
run: |
if ('${{ inputs.architecture == 'x86'}}' -eq 'true') {
$path = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFilesX86);
"path=$path" | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
}
if ('${{ inputs.architecture == 'x64'}}' -eq 'true') {
$path = [System.Environment]::GetFolderPath([System.Environment+SpecialFolder]::ProgramFiles);
"path=$path" | Out-File -FilePath $env:GITHUB_OUTPUT -Append;
}
shell: pwsh
37 changes: 37 additions & 0 deletions .github/actions/setup-dotnet-macos-rosetta/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Setup .NET
description: Setup .NET using the provided target framework and architecture

inputs:
target_framework:
description: 'The .NET target framework to setup'
required: true
target_framework_array:
description: 'The .NET target frameworks to setup'
required: true

runs:
using: "composite"
steps:
- name: Get .NET Channels
uses: ./.github/actions/get-dotnet-channel
id: get_channels
with:
target_framework: ${{inputs.target_framework}}
target_framework_array: ${{inputs.target_framework_array}}

- name: Setup .NET x64 ${{steps.get_channels.outputs.channels_multiline}}
uses: dlemstra/setup-dotnet@add-architecture-option
with:
dotnet-architecture: x64
dotnet-version: |
${{steps.get_channels.outputs.channel}}
${{steps.get_channels.outputs.channels_multiline}}
env:
DOTNET_INSTALL_DIR: /Users/runner/.dotnet/x64

- name: Setup .NET ${{steps.get_channels.outputs.channels_multiline}}
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{steps.get_channels.outputs.channel}}
${{steps.get_channels.outputs.channels_multiline}}
30 changes: 30 additions & 0 deletions .github/actions/setup-dotnet-unix/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Setup .NET
description: Setup .NET using the provided target framework and architecture

inputs:
target_framework:
description: 'The .NET target framework to setup'
required: true
target_framework_array:
description: 'The .NET target frameworks to setup'
required: true

runs:
using: "composite"
steps:
- name: Setup .NET Sdk
uses: actions/setup-dotnet@v4

- name: Get .NET Channels
uses: ./.github/actions/get-dotnet-channel
id: get_channels
with:
target_framework: ${{inputs.target_framework}}
target_framework_array: ${{inputs.target_framework_array}}

- name: Setup .NET ${{steps.get_channels.outputs.channels_multiline}}
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{steps.get_channels.outputs.channel}}
${{steps.get_channels.outputs.channels_multiline}}
48 changes: 48 additions & 0 deletions .github/actions/setup-dotnet-windows/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Setup .NET Windows
description: Setup .NET for Windows using the provided target framework and architecture

inputs:
architecture:
description: 'The .NET architecture to setup'
required: true
target_framework:
description: 'The .NET target framework to setup'
required: true
target_framework_array:
description: 'The .NET target frameworks to setup'
required: true

runs:
using: "composite"
steps:
- name: Get .NET Channel for ${{inputs.target_framework}}
uses: ./.github/actions/get-dotnet-channel
id: get_channels
with:
target_framework: ${{inputs.target_framework}}
target_framework_array: ${{inputs.target_framework_array}}

- name: Get Program Files path for x86
uses: ./.github/actions/get-program-files
if: ${{inputs.architecture == 'x86'}}
id: get-program-files-x86
with:
architecture: x86

- name: Setup .NET x86 ${{steps.get_channels.outputs.channels_multiline}}
uses: dlemstra/setup-dotnet@add-architecture-option
if: ${{inputs.architecture == 'x86'}}
with:
dotnet-architecture: x86
dotnet-version: |
${{steps.get_channels.outputs.channel}}
${{steps.get_channels.outputs.channels_multiline}}
env:
DOTNET_INSTALL_DIR: ${{steps.get-program-files-x86.outputs.path}}/dotnet

- name: Setup .NET ${{inputs.architecture}} ${{steps.get_channels.outputs.channels_multiline}}
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
${{steps.get_channels.outputs.channel}}
${{steps.get_channels.outputs.channels_multiline}}
28 changes: 28 additions & 0 deletions .github/actions/setup-mono-windows/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Setup Mono Windows
description: Setup Mono for Windows using the latest version

inputs:
architecture:
description: 'The architecture to setup Mono for'
required: true
version:
description: 'The Mono version to install'
required: false

outputs:
path:
description: 'The Mono path for the architecture'
value: '${{steps.get-program-files.outputs.path}}/Mono/bin/mono.exe'

runs:
using: "composite"
steps:
- name: Setup Mono
run: choco install mono --yes --no-progress --${{inputs.architecture}} ${{(inputs.version != '' && '--version=') || ''}}${{inputs.version}} --ignore-checksums
shell: pwsh

- name: Get Program Files path for ${{inputs.architecture}}
uses: ./.github/actions/get-program-files
id: get-program-files
with:
architecture: ${{inputs.architecture}}
24 changes: 24 additions & 0 deletions .github/actions/setup-wine-macos/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Install Wine on OS X
description: Install Wine on OS X

runs:
using: "composite"
steps:
# wine@staging v9.17
- run: |
curl -L ${{env.WINE_CASK}} > [email protected];
brew install --cask [email protected];
rm [email protected];
shell: bash
env:
WINE_CASK: https://raw.githubusercontent.com/Homebrew/homebrew-cask/2f29727c9961e8159df6dc19db315bc7783a4b99/Casks/w/wine%40staging.rb
# We can't use /usr/share/wine/mono because it's read-only
# We can't use /opt/wine/mono because it's read-only
- run: |
mkdir -p ~/.wine/share/wine/mono
curl -L -o mono.tar.xz ${{env.WINE_MONO}}
tar -xf mono.tar.xz -C ~/.wine/share/wine/mono
shell: bash
env:
WINE_MONO: https://github.com/madewokherd/wine-mono/releases/download/wine-mono-9.3.0/wine-mono-9.3.0-x86.tar.xz
30 changes: 30 additions & 0 deletions .github/actions/setup-wine-ubuntu/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Install Wine on Ubuntu
description: Install Wine on Ubuntu

runs:
using: "composite"
steps:
- run: sudo dpkg --add-architecture i386
shell: bash

- run: |
sudo mkdir -pm755 /etc/apt/keyrings;
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key;
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/jammy/winehq-jammy.sources
shell: bash
- run: sudo apt-get update
shell: bash

- run: sudo apt install --install-recommends winehq-staging=${{env.WINE_VERSION}}
shell: bash
env:
WINE_VERSION: 9.17~jammy-1

- run: |
mkdir -p /usr/share/wine/mono
curl -L -o mono.tar.xz ${{env.WINE_MONO}}
tar -xf mono.tar.xz -C /usr/share/wine/mono
shell: bash
env:
WINE_MONO: https://github.com/madewokherd/wine-mono/releases/download/wine-mono-9.3.0/wine-mono-9.3.0-x86.tar.xz
23 changes: 23 additions & 0 deletions .github/actions/test-build-artifacts-upload/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Upload Build Artifacts
description: Upload the build artifacts for the specified image and build configuration

inputs:
image:
description: 'The image to use'
required: true
architecture:
description: 'The architecture to use'
required: true
build_configuration:
description: 'The build configuration to use'
required: true

runs:
using: "composite"
steps:
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-${{inputs.image}}-${{inputs.architecture}}-${{inputs.build_configuration}}
path: artifacts/
retention-days: 7
Loading

0 comments on commit 2fdf836

Please sign in to comment.