Skip to content

Wrangling with GitHub Actions Runners and Homebrew #331

Wrangling with GitHub Actions Runners and Homebrew

Wrangling with GitHub Actions Runners and Homebrew #331

Workflow file for this run

name: Remote Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
fullName:
description: The full name of the release
default: Adept 2.8
required: true
type: string
shortVersion:
description: The short version number
default: "2.8"
required: true
type: string
longVersion:
description: The long version number
default: "2.8.0"
required: true
type: string
alternativeBinaryName:
description: The alternative binary name
default: "adept2-8"
required: true
type: string
env:
BUILD_TYPE: Release
CTEST_OUTPUT_ON_FAILURE: On
IS_GITHUB_WORKFLOW: On
jobs:
build:
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
defaults:
run:
working-directory: ${{github.workspace}}
name: ${{ format('Build / {0}', matrix.os) }}
steps:
- uses: actions/checkout@v3
- name: Get latest CMake and Ninja
uses: lukka/get-cmake@latest
- name: Configure to use MinGW-w64 (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
export CC=x86_64-w64-mingw32-gcc
export CXX=x86_64-w64-mingw32-g++
- name: Utilize cached LLVM if available (Windows)
if: matrix.os == 'windows-latest'
uses: actions/cache@v2
id: llvm
with:
path: ${{github.workspace}}/llvm
key: ${{runner.os}}-cache-llvm-project-16.0.6-${{ hashFiles('llvm/**/*.txt') }}
# For some god-forsaken reason, there is no prebuilt version of LLVM for developing on Windows.
# Every version comes with llvm-config, LLVMConfig.cmake, and other files needed, expect Windows!
# Which means we're gonna have to spend an hour or so compiling from scratch (Github willing)
# At least we have ninja
- name: Download LLVM Source Code (Windows)
if: steps.llvm.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
run: curl -o llvm-source-tree.tar.xz -L https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.6/llvm-project-16.0.6.src.tar.xz
- name: Extract LLVM Source Code (Windows)
if: steps.llvm.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
run: |
7z x llvm-source-tree.tar.xz
tar xf llvm-source-tree.tar
mv llvm-project-16.0.6.src llvm
- name: Build LLVM from Source (Windows)
if: steps.llvm.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
working-directory: ${{github.workspace}}/llvm/llvm
shell: bash
run: |
mkdir build
cmake -B build -DCMAKE_BUILD_TYPE="Release" -G Ninja
cmake --build build
- name: Download and extract libcurl (Windows)
if: ${{ matrix.os == 'windows-latest' }}
shell: bash
run: |
curl -o curl.zip -L https://curl.se/windows/dl-8.2.1_11/curl-8.2.1_11-win64-mingw.zip
unzip curl.zip
mv curl-8.2.1_11-win64-mingw libcurl
- name: Download static zlib libraries (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
C:\msys64\usr\bin\pacman -S mingw-w64-x86_64-zlib --noconfirm
- name: Download zstd library (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
C:\msys64\usr\bin\pacman -S mingw-w64-x86_64-zstd --noconfirm
- name: Configure (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
$env:Path = "C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin;$env:Path"
cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH="${{github.workspace}}/llvm/llvm/build;C:\msys64\mingw64" -DCMAKE_LIBRARY_PATH=C:\msys64\mingw64\lib -DCURL_LIBRARY=curl -DCURL_LIBRARY_DIRS=${{github.workspace}}/libcurl/lib -DCURL_INCLUDE_DIR=libcurl/include -DADEPT_LINK_LLVM_STATIC=On -B ${{github.workspace}}/build -G Ninja
env:
LLVM_DIR: ${{github.workspace}}/llvm/llvm/build
zstd_DIR: C:\msys64\mingw64
zstd_LIBRARY: C:\msys64\mingw64\lib\libzstd.a
ZLIB_INCLUDE_DIR: C:\msys64\mingw64\include
ZLIB_LIBRARY: C:\msys64\mingw64\lib\libz.a
- name: Install LLVM and dependencies (macOS)
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install llvm
brew install zstd
- name: Install LLVM and dependencies (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y libncurses5
sudo apt-get install -y libcurl4-openssl-dev
sudo apt-get remove -y llvm-13
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install zstd
brew install llvm
brew ls -v zstd
- name: Configure (macOS)
if: ${{ matrix.os == 'macos-latest' }}
run: |
echo
cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DADEPT_LINK_LLVM_STATIC=On -B ${{github.workspace}}/build -G Ninja
env:
CC: /opt/homebrew/opt/llvm/bin/clang
LLVM_DIR: /opt/homebrew/opt/llvm
zstd_DIR: /usr/local/opt/zstd
LD_LIBRARY_PATH: ""
LIBCXXABI_USE_LLVM_UNWINDER: "OFF"
COMPILER_RT_USE_LLVM_UNWINDER: "OFF"
CFLAGS: -DBUILD_SHARED_LIBS=OFF LIBCXXABI_USE_LLVM_UNWINDER=OFF COMPILER_RT_USE_LLVM_UNWINDER=OFF
CXXFLAGS: -DBUILD_SHARED_LIBS=OFF LIBCXXABI_USE_LLVM_UNWINDER=OFF COMPILER_RT_USE_LLVM_UNWINDER=OFF
- name: Configure (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH="/usr/lib/x86_64-linux-gnu" -DADEPT_LINK_LLVM_STATIC=On -B ${{github.workspace}}/build -G Ninja
env:
LLVM_DIR: /home/linuxbrew/.linuxbrew/opt/llvm
zstd_DIR: /home/linuxbrew/.linuxbrew/opt/zstd
- name: Build
run: |
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Archive Build Result
uses: a7ul/tar-action@v1.1.3
with:
command: c
files: build
outPath: build-${{ matrix.os }}.tar.gz
- name: Archive E2E Infrastructure
uses: a7ul/tar-action@v1.1.3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
command: c
cwd: tests
files: e2e
outPath: e2e.tar.gz
- name: Archive Support Libraries Infrastructure
uses: a7ul/tar-action@v1.1.3
if: ${{ matrix.os == 'windows-latest' }}
with:
command: c
files: res
outPath: res.tar.gz
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.os }}-archive
path: build-${{ matrix.os }}.tar.gz
- name: Upload E2E Testing Infrastructure Artifact
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
name: e2e-archive
path: e2e.tar.gz
- name: Upload Resources Artifact
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'windows-latest' }}
with:
name: res
path: res.tar.gz
- name: Upload LICENSE Artifact
uses: actions/upload-artifact@v3
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
name: LICENSE
path: LICENSE
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
name: ${{ format('Test / {0}', matrix.os) }}
steps:
- name: Setup Python
uses: actions/setup-python@v3.1.2
with:
python-version: '3.x'
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: build-${{ matrix.os }}-archive
- name: Download E2E Testing Infrastructure Artifact
uses: actions/download-artifact@v3
with:
name: e2e-archive
- name: Unpack 1/2
uses: a7ul/tar-action@v1.1.3
with:
command: x
files: e2e.tar.gz
- name: Unpack 2/2
uses: a7ul/tar-action@v1.1.3
with:
command: x
files: build-${{ matrix.os }}.tar.gz
- name: Install libcurl for curl demo (Ubuntu)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev
- name: Unit Test
shell: bash
run: build/tests/unit/UnitTestRunner
- name: E2E Test (Windows)
if: ${{ matrix.os == 'windows-latest' }}
working-directory: ${{github.workspace}}/e2e
run: |
$env:Path = "C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/bin;$env:Path"
python3 e2e-runner.py ../build/adept
- name: E2E Test (Unix)
if: ${{ matrix.os != 'windows-latest' }}
working-directory: ${{github.workspace}}/e2e
run: |
python3 e2e-runner.py ../build/adept
build-windows-installer:
name: Installer / windows-latest
needs: test
runs-on: windows-latest
steps:
- name: Get workflow dispatch inputs (workflow dispatch)
if: github.event_name == 'workflow_dispatch'
shell: bash
run: |
echo 'fullName=${{github.event.inputs.fullName}}' >> $GITHUB_ENV
echo 'shortVersion=${{github.event.inputs.shortVersion}}' >> $GITHUB_ENV
echo 'longVersion=${{github.event.inputs.longVersion}}' >> $GITHUB_ENV
echo 'alternativeBinaryName=${{github.event.inputs.alternativeBinaryName}}' >> $GITHUB_ENV
- name: Get default inputs (push / pr)
if: github.event_name != 'workflow_dispatch'
shell: bash
run: |
echo 'fullName=Adept Nightly' >> $GITHUB_ENV
echo 'shortVersion=nightly' >> $GITHUB_ENV
echo 'longVersion=nightly' >> $GITHUB_ENV
echo 'alternativeBinaryName=adept-nightly' >> $GITHUB_ENV
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: build-windows-latest-archive
- name: Download Support Libraries Artifact
uses: actions/download-artifact@v3
with:
name: res
- name: Download LICENSE Artifact
uses: actions/download-artifact@v3
with:
name: LICENSE
- name: Unpack Build Artifact
uses: a7ul/tar-action@v1.1.3
with:
command: x
files: build-windows-latest.tar.gz
- name: Unpack Support Libraries Artifact
uses: a7ul/tar-action@v1.1.3
with:
command: x
files: res.tar.gz
- name: Checkout Adept Standard Library
uses: actions/checkout@v3
with:
repository: 'AdeptLanguage/AdeptImport'
path: 'AdeptImport'
- name: Checkout Adept Default Configuration
uses: actions/checkout@v3
with:
repository: 'AdeptLanguage/Config'
path: 'AdeptConfig'
- name: Checkout Windows Installer Source Code
uses: actions/checkout@v3
with:
repository: 'IsaacShelton/AdeptWindowsInstaller'
path: 'AdeptWindowsInstaller'
- name: Pre-package
shell: bash
run: mkdir -p stage
- name: Generate GUID
shell: bash
run: echo -n "::set-output name=guid::" && python3 AdeptWindowsInstaller/generate-guid.py
id: guid
- name: Perform substitutions
shell: bash
run: >
sed -i AdeptWindowsInstaller/Adept-X.X-installer.iss -e 's/__STAGING_AREA__/..\/stage/g' -e 's/__OUTPUT_DIRECTORY__/./g' -e 's/__FAVICON_DIRECTORY__/..\/res/g' -e 's/adeptX-X/${{env.alternativeBinaryName}}/g' -e 's/X.X/${{env.shortVersion}}/g' -e 's/{7D143E16-9268-4F20-A0FA-8B30D8B14ECA}/${{steps.guid.outputs.guid}}/g'
- name: Stage
shell: bash
run: |
mkdir -p stage
mv build/adept.exe stage/adept.exe
mv res/necessities/windows/* stage/
mv AdeptWindowsInstaller/adeptX-X.bat stage/${{env.alternativeBinaryName}}.bat
mv AdeptConfig/adept.config stage/adept.config
mv AdeptImport stage/import
mv LICENSE stage/LICENSE
- name: Install Inno Setup
run: choco install innosetup
- name: Package as Installer
run: iscc AdeptWindowsInstaller/Adept-X.X-installer.iss
- name: Package as Standalone
run: |
mv stage adept-${{env.shortVersion}}-standalone
powershell Compress-Archive adept-${{env.shortVersion}}-standalone Adept-${{env.shortVersion}}-standalone-x86_64-Windows.zip
- name: Upload Windows Installer Artifact
uses: actions/upload-artifact@v3
with:
name: windows-installer
path: AdeptWindowsInstaller/Adept-${{env.shortVersion}}-installer.exe
- name: Upload Windows Standalone Artifact
uses: actions/upload-artifact@v3
with:
name: windows-standalone
path: Adept-${{env.shortVersion}}-standalone-x86_64-Windows.zip
build-macos-installer:
name: Installer / macos-latest
needs: test
runs-on: macos-latest
steps:
- name: Get workflow dispatch inputs (workflow dispatch)
if: github.event_name == 'workflow_dispatch'
shell: bash
run: |
echo 'fullName=${{github.event.inputs.fullName}}' >> $GITHUB_ENV
echo 'shortVersion=${{github.event.inputs.shortVersion}}' >> $GITHUB_ENV
echo 'longVersion=${{github.event.inputs.longVersion}}' >> $GITHUB_ENV
echo 'alternativeBinaryName=${{github.event.inputs.alternativeBinaryName}}' >> $GITHUB_ENV
- name: Get default inputs (push / pr)
if: github.event_name != 'workflow_dispatch'
shell: bash
run: |
echo 'fullName=Adept Nightly' >> $GITHUB_ENV
echo 'shortVersion=nightly' >> $GITHUB_ENV
echo 'longVersion=nightly' >> $GITHUB_ENV
echo 'alternativeBinaryName=adept-nightly' >> $GITHUB_ENV
- name: Setup Python
uses: actions/setup-python@v3.1.2
with:
python-version: '3.x'
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: build-macos-latest-archive
- name: Unpack
uses: a7ul/tar-action@v1.1.3
with:
command: x
files: build-macos-latest.tar.gz
- name: Checkout macOS Installer Builder
uses: actions/checkout@v3
with:
repository: 'IsaacShelton/macOS-installer-builder'
ref: 'v1.0.0'
path: 'macOS-installer-builder'
- name: Checkout Adept Standard Library
uses: actions/checkout@v3
with:
repository: 'AdeptLanguage/AdeptImport'
path: 'AdeptImport'
- name: Checkout Adept Default Configuration
uses: actions/checkout@v3
with:
repository: 'AdeptLanguage/Config'
path: 'AdeptConfig'
- name: Download Adept Cross Compilation Support
run: wget -O AdeptCrossCompilation.zip https://github.com/IsaacShelton/AdeptCrossCompilation/releases/download/2.4/AdeptCrossCompilation-MacOS-to-Windows.zip
- name: Unpack Cross Compilation Support
run: unzip AdeptCrossCompilation.zip
- name: Stage Application Files
working-directory: ${{github.workspace}}/macOS-installer-builder
run: |
rm -rf stage/application
mkdir -p stage/application
mv ../AdeptImport stage/application/import
mv ../AdeptCrossCompilation-MacOS-to-Windows/cross-compile-windows stage/application/cross-compile-windows
mv ../AdeptConfig/adept.config stage/application/adept.config
mv ../build/adept stage/application/adept
- name: Stage Installer Files
working-directory: ${{github.workspace}}/macOS-installer-builder
run: |
sed -i '' -e 's/Adept 2.6/${{env.fullName}}/g' stage/installer/welcome.html
sed -i '' -e 's/Adept 2.6/${{env.fullName}}/g' -e s/adept2-6/${{env.alternativeBinaryName}}/g stage/installer/conclusion.html
sed -i '' -e s/adept2-6/${{env.alternativeBinaryName}}/g -e s/2.6.0/${{env.longVersion}}/g stage/installer/postinstall
- name: Package as Installer
working-directory: ${{github.workspace}}/macOS-installer-builder
run: |
python3 src/build-installer.py Adept ${{env.longVersion}}
mv build/Adept-${{env.longVersion}}-installer.pkg build/Adept-${{env.shortVersion}}-installer.pkg
- name: Package as Standalone
working-directory: ${{github.workspace}}/macOS-installer-builder
run: |
mv stage/application adept-${{env.shortVersion}}-standalone
zip -vr Adept-${{env.shortVersion}}-standalone-arm64-MacOS.zip adept-${{env.shortVersion}}-standalone/ -x "*.DS_Store"
- name: Upload MacOS Installer Artifact
uses: actions/upload-artifact@v3
with:
name: macos-installer
path: macOS-installer-builder/build/Adept-${{env.shortVersion}}-installer.pkg
- name: Upload MacOS Standalone Artifact
uses: actions/upload-artifact@v3
with:
name: macos-standalone
path: macOS-installer-builder/Adept-${{env.shortVersion}}-standalone-arm64-MacOS.zip
deploy:
name: Deploy
needs: [test, build-windows-installer, build-macos-installer]
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- name: Get workflow dispatch inputs (workflow dispatch)
if: github.event_name == 'workflow_dispatch'
shell: bash
run: |
echo 'fullName=${{github.event.inputs.fullName}}' >> $GITHUB_ENV
echo 'shortVersion=${{github.event.inputs.shortVersion}}' >> $GITHUB_ENV
echo 'longVersion=${{github.event.inputs.longVersion}}' >> $GITHUB_ENV
echo 'alternativeBinaryName=${{github.event.inputs.alternativeBinaryName}}' >> $GITHUB_ENV
echo 'releaseName=${{github.event.inputs.fullName}}' >> $GITHUB_ENV
echo 'releaseTagName=v${{github.event.inputs.shortVersion}}' >> $GITHUB_ENV
- name: Get default inputs (push / pr)
if: github.event_name != 'workflow_dispatch'
shell: bash
run: |
echo 'fullName=Adept Nightly' >> $GITHUB_ENV
echo 'shortVersion=nightly' >> $GITHUB_ENV
echo 'longVersion=nightly' >> $GITHUB_ENV
echo 'alternativeBinaryName=adept-nightly' >> $GITHUB_ENV
echo 'releaseName=Nightly' >> $GITHUB_ENV
echo 'releaseTagName=Nightly' >> $GITHUB_ENV
- name: Download Build Artifact (windows-latest)
uses: actions/download-artifact@v3
with:
name: build-windows-latest-archive
- name: Download Build Artifact (macos-latest)
uses: actions/download-artifact@v3
with:
name: build-macos-latest-archive
- name: Download Build Artifact (ubuntu-latest)
uses: actions/download-artifact@v3
with:
name: build-ubuntu-latest-archive
- name: Checkout Adept Default Configuration
uses: actions/checkout@v3
with:
repository: 'AdeptLanguage/Config'
path: 'AdeptConfig'
- name: Checkout Adept Standard Library
uses: actions/checkout@v3
with:
repository: 'AdeptLanguage/AdeptImport'
path: 'AdeptImport'
- name: Download Windows Installer Artifact
uses: actions/download-artifact@v3
with:
name: windows-installer
- name: Download Windows Standalone Artifact
uses: actions/download-artifact@v3
with:
name: windows-standalone
- name: Download macOS Installer Artifact
uses: actions/download-artifact@v3
with:
name: macos-installer
- name: Download macOS Standalone Artifact
uses: actions/download-artifact@v3
with:
name: macos-standalone
- name: Pre-Unpack
run: mkdir windows-latest macos-latest ubuntu-latest
- name: Unpack Windows Build
uses: a7ul/tar-action@v1.1.3
with:
command: x
cwd: windows-latest
files: build-windows-latest.tar.gz
- name: Unpack macOS Build
uses: a7ul/tar-action@v1.1.3
with:
command: x
cwd: macos-latest
files: build-macos-latest.tar.gz
- name: Unpack Ubuntu Build
uses: a7ul/tar-action@v1.1.3
with:
command: x
cwd: ubuntu-latest
files: build-ubuntu-latest.tar.gz
- name: Package as Standalone for Ubuntu
working-directory: ${{github.workspace}}
run: |
mkdir -p adept-${{env.shortVersion}}-standalone
cp ubuntu-latest/build/adept adept-${{env.shortVersion}}-standalone/adept
mv AdeptConfig/adept.config adept-${{env.shortVersion}}-standalone/adept.config
mv AdeptImport adept-${{env.shortVersion}}-standalone/import
zip -r Adept-${{env.shortVersion}}-standalone-x86_64-Ubuntu.zip adept-${{env.shortVersion}}-standalone
- name: Stage
run: |
mkdir stage
mv Adept-${{env.shortVersion}}-installer.pkg stage/MacOS-arm64-Installer-Adept-${{env.shortVersion}}.pkg
mv Adept-${{env.shortVersion}}-installer.exe stage/Windows-x86_64-Installer-Adept-${{env.shortVersion}}.exe
mv Adept-${{env.shortVersion}}-standalone-x86_64-Windows.zip stage/Windows-x86_64-Standalone-Adept-${{env.shortVersion}}.zip
mv Adept-${{env.shortVersion}}-standalone-arm64-MacOS.zip stage/MacOS-arm64-Standalone-Adept-${{env.shortVersion}}.zip
mv Adept-${{env.shortVersion}}-standalone-x86_64-Ubuntu.zip stage/Ubuntu-x86_64-Standalone-Adept-${{env.shortVersion}}.zip
- name: Get current date
id: date
run: echo "::set-output name=date::$(date '+%B %d %Y at %l:%M %p %Z')"
- name: Release
uses: IsaacShelton/update-existing-release@v1.3.4
with:
token: ${{secrets.GITHUB_TOKEN}}
release: ${{env.releaseName}}
body: ${{ format('Last built on {0} - {1}', steps.date.outputs.date, github.sha) }}
tag: ${{env.releaseTagName}}
replace: true
files: >
stage/MacOS-arm64-Installer-Adept-${{env.shortVersion}}.pkg
stage/MacOS-arm64-Standalone-Adept-${{env.shortVersion}}.zip
stage/Windows-x86_64-Installer-Adept-${{env.shortVersion}}.exe
stage/Windows-x86_64-Standalone-Adept-${{env.shortVersion}}.zip
stage/Ubuntu-x86_64-Standalone-Adept-${{env.shortVersion}}.zip