Skip to content

Commit

Permalink
Attempt at refactoring GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum committed May 18, 2024
1 parent 2ea222b commit 08923c5
Show file tree
Hide file tree
Showing 7 changed files with 272 additions and 279 deletions.
28 changes: 28 additions & 0 deletions .github/actions/setup-d-compiler/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Set-up D compiler for the selected target
description: Install LDC and add the demanded target if needed.

inputs:
target-triple:
description: Target triple
required: true

runs:
- uses: dlang-community/setup-dlang@v1
with:
compiler: ldc-1.33.0

- if: inputs.target-triple == 'aarch64-linux-gnu'
name: "Set-up AArch64-linux cross-compiler."
uses: ./.github/actions/target-aarch64-linux-gnu

- if: inputs.target-triple == 'arm64-apple-macos'
name: "Set-up ARM64-macOS cross-compiler."
uses: ./.github/actions/target-arm64-apple-macos

- if: inputs.target-triple == 'x86_64-apple-darwin'
name: "Set-up x86_64-macOS cross-compiler."
uses: ./.github/actions/target-x86_64-apple-darwin

- if: inputs.target-triple == 'x86_64-windows-msvc'
name: "Set-up x86_64-windows cross-compiler."
uses: ./.github/actions/target-x86_64-windows-msvc
51 changes: 51 additions & 0 deletions .github/actions/target-aarch64-linux-gnu/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Set-up LDC to target Linux AArch64
description: Adds a working aarch64-linux-gnu target to LDC.

runs:
using: composite
steps:
- name: Install Clang
shell: bash
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Set-up macOS cross-compilation
shell: bash
run: |
mkdir -p $HOME/.ldc/
LDC_VERSION=$(ldc2 --version | head -n 1 | grep -oE "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*")
curl -LO https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.0.sdk.tar.xz
tar -xf ./MacOSX11.0.sdk.tar.xz -C $HOME
cp $(dirname $(which ldc2))/../etc/ldc2.conf $HOME/.ldc/ldc2.conf
cat << EOF | tee $HOME/.ldc/ldc2.conf
"arm64-apple-macos":
{
// default switches injected before all explicit command-line switches
switches = [
"-gcc=clang",
"-linker=lld-15",
"-Xcc=-target",
"-Xcc=arm64-apple-macos",
"-Xcc=-isysroot",
"-Xcc=$HOME/MacOSX11.0.sdk",
"-Xcc=-F",
"-Xcc=$HOME/ldc2-$LDC_VERSION-osx-arm64/lib",
"-Xcc=-mmacosx-version-min=12.6",
"-L=-platform_version",
"-L=macos",
"-L=12.6.0",
"-L=0.0.0",
"-defaultlib=phobos2-ldc,druntime-ldc",
];
// default switches appended after all explicit command-line switches
post-switches = [
"-I$HOME/ldc2-$LDC_VERSION-osx-arm64/import",
];
// default directories to be searched for libraries when linking
lib-dirs = [
"$HOME/ldc2-$LDC_VERSION-osx-arm64/lib",
];
};
EOF
mkdir $HOME/ldc-macos
curl -LO https://github.com/ldc-developers/ldc/releases/download/v$LDC_VERSION/ldc2-$LDC_VERSION-osx-arm64.tar.xz
tar -xf ./ldc2-$LDC_VERSION-osx-arm64.tar.xz -C $HOME
51 changes: 51 additions & 0 deletions .github/actions/target-arm64-apple-macos/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Set-up LDC to target macOS ARM64
description: Adds a working arm64-apple-macos target to LDC.

runs:
using: composite
steps:
- name: Install Clang
shell: bash
run: sudo apt-get update && sudo apt-get install -y clang lld

- name: Set-up macOS cross-compilation
shell: bash
run: |
mkdir -p $HOME/.ldc/
LDC_VERSION=$(ldc2 --version | head -n 1 | grep -oE "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*")
curl -LO https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.0.sdk.tar.xz
tar -xf ./MacOSX11.0.sdk.tar.xz -C $HOME
cp $(dirname $(which ldc2))/../etc/ldc2.conf $HOME/.ldc/ldc2.conf
cat << EOF | tee $HOME/.ldc/ldc2.conf
"arm64-apple-macos":
{
// default switches injected before all explicit command-line switches
switches = [
"-gcc=clang",
"-linker=lld-15",
"-Xcc=-target",
"-Xcc=arm64-apple-macos",
"-Xcc=-isysroot",
"-Xcc=$HOME/MacOSX11.0.sdk",
"-Xcc=-F",
"-Xcc=$HOME/ldc2-$LDC_VERSION-osx-arm64/lib",
"-Xcc=-mmacosx-version-min=12.6",
"-L=-platform_version",
"-L=macos",
"-L=12.6.0",
"-L=0.0.0",
"-defaultlib=phobos2-ldc,druntime-ldc",
];
// default switches appended after all explicit command-line switches
post-switches = [
"-I$HOME/ldc2-$LDC_VERSION-osx-arm64/import",
];
// default directories to be searched for libraries when linking
lib-dirs = [
"$HOME/ldc2-$LDC_VERSION-osx-arm64/lib",
];
};
EOF
mkdir $HOME/ldc-macos
curl -LO https://github.com/ldc-developers/ldc/releases/download/v$LDC_VERSION/ldc2-$LDC_VERSION-osx-arm64.tar.xz
tar -xf ./ldc2-$LDC_VERSION-osx-arm64.tar.xz -C $HOME
51 changes: 51 additions & 0 deletions .github/actions/target-x86_64-apple-darwin/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Set-up LDC to target macOS ARM64
description: Adds a working arm64-apple-macos target to LDC.

runs:
using: composite
steps:
- name: Install Clang
shell: bash
run: sudo apt-get update && sudo apt-get install -y clang lld

- name: Set-up macOS cross-compilation
shell: bash
run: |
mkdir -p $HOME/.ldc/
LDC_VERSION=$(ldc2 --version | head -n 1 | grep -oE "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*")
curl -LO https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.0.sdk.tar.xz
tar -xf ./MacOSX11.0.sdk.tar.xz -C $HOME
cp $(dirname $(which ldc2))/../etc/ldc2.conf $HOME/.ldc/ldc2.conf
cat << EOF | tee $HOME/.ldc/ldc2.conf
"x86_64-apple-darwin":
{
// default switches injected before all explicit command-line switches
switches = [
"-gcc=clang",
"-linker=lld-15",
"-Xcc=-target",
"-Xcc=x86_64-apple-darwin",
"-Xcc=-isysroot",
"-Xcc=$HOME/MacOSX11.0.sdk",
"-Xcc=-F",
"-Xcc=$HOME/ldc2-$LDC_VERSION-osx-x86_64/lib",
"-Xcc=-mmacosx-version-min=12.6",
"-L=-platform_version",
"-L=macos",
"-L=12.6.0",
"-L=0.0.0",
"-defaultlib=phobos2-ldc,druntime-ldc",
];
// default switches appended after all explicit command-line switches
post-switches = [
"-I$HOME/ldc2-$LDC_VERSION-osx-x86_64/import",
];
// default directories to be searched for libraries when linking
lib-dirs = [
"$HOME/ldc2-$LDC_VERSION-osx-x86_64/lib",
];
};
EOF
mkdir $HOME/ldc-macos
curl -LO https://github.com/ldc-developers/ldc/releases/download/v$LDC_VERSION/ldc2-$LDC_VERSION-osx-x86_64.tar.xz
tar -xf ./ldc2-$LDC_VERSION-osx-x86_64.tar.xz -C $HOME
34 changes: 34 additions & 0 deletions .github/actions/target-x86_64-windows-msvc/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Set-up LDC to target Windows
description: Adds a working x86_64-windows-msvc target to LDC.

runs:
using: composite
steps:
- name: Install Clang
shell: bash
run: sudo apt-get update && sudo apt-get install -y clang lld 7z

- name: Set-up macOS cross-compilation
shell: bash
run: |
mkdir -p $HOME/.ldc/
LDC_VERSION=$(ldc2 --version | head -n 1 | grep -oE "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*")
cat << EOF | tee $HOME/.ldc/ldc2.conf
"x86_64-.*-windows-msvc":
{
// default switches injected before all explicit command-line switches
switches = [
"-defaultlib=phobos2-ldc,druntime-ldc",
];
// default switches appended after all explicit command-line switches
post-switches = [
"-I$HOME/ldc2-$LDC_VERSION-windows-x64/import",
];
// default directories to be searched for libraries when linking
lib-dirs = [
"$HOME/ldc2-$LDC_VERSION-windows-x64/lib",
];
};
EOF
curl -LO https://github.com/ldc-developers/ldc/releases/download/v$LDC_VERSION/ldc2-$LDC_VERSION-windows-x64.7z
7z x ./ldc2-$LDC_VERSION-windows-x64.7z -o$HOME
19 changes: 19 additions & 0 deletions .github/actions/write-version-file/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Write version file
description: Write the current commit SHA in the version.d source file

inputs:
version-text:
description: Version text
required: false
default: 'Sideloader automated build, branch ${{ github.ref_name }}, commit ${{ github.sha }}'

runs:
using: composite
steps:
- name: Write commit SHA in the version file
shell: bash
run:
cat << EOF | tee source/version_string.d
module version_string;
enum versionStr = "${{ inputs.version-text }}";
EOF
Loading

0 comments on commit 08923c5

Please sign in to comment.