Skip to content

Commit

Permalink
Simplify most GitHub workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Dadoum authored May 18, 2024
1 parent 08923c5 commit 918224b
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 640 deletions.
36 changes: 36 additions & 0 deletions .github/actions/rename-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Rename files
description: Move files around in the output folder with consistent naming schemes.

inputs:
build-tag:
description: Tag to put in the file name

runs:
using: composite
steps:
- if: ${{ matrix.target == 'linux' }}
name: (Linux) Install dependencies
shell: bash
run: sudo apt-get install -y libz-dev elfutils

- if: ${{ matrix.target == 'macos' }}
name: (macOS) Rename files
shell: bash
run: mv "${{github.workspace}}/bin/sideloader" "${{github.workspace}}/bin/sideloader-${{ inputs.build-tag }}" # TODO make an app bundle

- if: ${{ matrix.target == 'windows' }}
name: (Windows) Rename files
shell: bash
run: |
mv "${{github.workspace}}/bin/sideloader.exe" "${{github.workspace}}/bin/sideloader-${{ inputs.build-tag }}.exe"
mv "${{github.workspace}}/bin/sideloader.pdb" "${{github.workspace}}/bin/sideloader-${{ inputs.build-tag }}.pdb"
- if: ${{ matrix.target == 'linux' }}
name: (Linux) Rename files
shell: bash
run: mv "${{github.workspace}}/bin/sideloader" "${{github.workspace}}/bin/sideloader-${{ inputs.build-tag }}"

- if: ${{ matrix.target == 'linux' }}
name: (Linux) Put debug symbols in a separate file
shell: bash
run: eu-strip --strip-debug -f "${{github.workspace}}/bin/sideloader-${{ inputs.build-tag }}.dbg" "${{github.workspace}}/bin/sideloader-${{ inputs.build-tag }}"
32 changes: 17 additions & 15 deletions .github/actions/setup-d-compiler/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ inputs:
required: true

runs:
- uses: dlang-community/setup-dlang@v1
with:
compiler: ldc-1.33.0
using: composite
steps:
- uses: dlang-community/setup-dlang@v1
with:
compiler: ldc-1.34.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 == '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 == '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-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
- if: inputs.target-triple == 'x86_64-windows-msvc'
name: "Set-up x86_64-windows cross-compiler."
uses: ./.github/actions/target-x86_64-windows-msvc
37 changes: 9 additions & 28 deletions .github/actions/target-aarch64-linux-gnu/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,29 @@ description: Adds a working aarch64-linux-gnu target to LDC.
runs:
using: composite
steps:
- name: Install Clang
- name: Install GCC
shell: bash
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
run: sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Set-up macOS cross-compilation
- name: Set-up aarch64 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":
"aarch64-.*-linux-gnu":
{
// 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",
"-gcc=aarch64-linux-gnu-gcc",
];
// default switches appended after all explicit command-line switches
post-switches = [
"-I$HOME/ldc2-$LDC_VERSION-osx-arm64/import",
"-I$HOME/ldc2-$LDC_VERSION-linux-aarch64/import",
];
// default directories to be searched for libraries when linking
lib-dirs = [
"$HOME/ldc2-$LDC_VERSION-osx-arm64/lib",
"$HOME/ldc2-$LDC_VERSION-linux-aarch64/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
curl -LO https://github.com/ldc-developers/ldc/releases/download/v$LDC_VERSION/ldc2-$LDC_VERSION-linux-aarch64.tar.xz
tar -xf ./ldc2-$LDC_VERSION-linux-aarch64.tar.xz -C $HOME
2 changes: 1 addition & 1 deletion .github/actions/target-arm64-apple-macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
steps:
- name: Install Clang
shell: bash
run: sudo apt-get update && sudo apt-get install -y clang lld
run: sudo apt-get install -y clang lld

- name: Set-up macOS cross-compilation
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/target-x86_64-apple-darwin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
steps:
- name: Install Clang
shell: bash
run: sudo apt-get update && sudo apt-get install -y clang lld
run: sudo apt-get install -y clang lld

- name: Set-up macOS cross-compilation
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/target-x86_64-windows-msvc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ runs:
steps:
- name: Install Clang
shell: bash
run: sudo apt-get update && sudo apt-get install -y clang lld 7z
run: sudo apt-get install -y clang lld 7zip

- name: Set-up macOS cross-compilation
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/write-version-file/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
steps:
- name: Write commit SHA in the version file
shell: bash
run:
run: |
cat << EOF | tee source/version_string.d
module version_string;
enum versionStr = "${{ inputs.version-text }}";
Expand Down
29 changes: 8 additions & 21 deletions .github/workflows/build-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- triple: 'x86_64-linux-gnu'
Expand All @@ -33,38 +34,24 @@ jobs:
with:
submodules: recursive

- name: Update APT repos
run: sudo apt-get update

- name: Set-up D compiler
uses: ./.github/actions/setup-d-compiler
with:
target-triple: ${{ matrix.triple }}

- if: ${{ matrix.target == 'linux' }}
name: (Linux) Install dependencies
run: sudo apt-get update && sudo apt-get install -y libz-dev elfutils

- name: Write version file
uses: ./.github/actions/write-version-file

- name: Build
run: dub build -b release-debug --compiler=ldc2 --arch ${{ matrix.triple }} :cli-frontend

- if: ${{ matrix.target == 'macos' }}
name: (macOS) Rename
run: mv "${{github.workspace}}/bin/sideloader" "${{github.workspace}}/bin/sideloader-cli-${{ matrix.triple }}" # TODO make an app bundle

- if: ${{ matrix.target == 'windows' }}
name: (Windows) Rename
run: |
mv "${{github.workspace}}/bin/sideloader.exe" "${{github.workspace}}/bin/sideloader-cli-${{ matrix.triple }}.exe"
mv "${{github.workspace}}/bin/sideloader.pdb" "${{github.workspace}}/bin/sideloader-cli-${{ matrix.triple }}.pdb"
- if: ${{ matrix.target == 'linux' }}
name: (Linux) Rename
run: mv "${{github.workspace}}/bin/sideloader" "${{github.workspace}}/bin/sideloader-cli-${{ matrix.triple }}"

- if: ${{ matrix.target == 'linux' }}
name: (Linux) Put debug symbols in a separate file
run: eu-strip --strip-debug -f "${{github.workspace}}/bin/sideloader-cli-${{ matrix.triple }}.dbg" "${{github.workspace}}/bin/sideloader-cli-${{ matrix.triple }}"
- name: Move files around for artifcation
uses: ./.github/actions/rename-files
with:
build-tag: cli-${{ matrix.triple }}

- uses: actions/upload-artifact@v3
with:
Expand Down
Loading

0 comments on commit 918224b

Please sign in to comment.