Update build.yml
workflow to cross-compile linux binaries for x86_64
and aarch64
#376
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
pull_request: | |
branches: | |
- master | |
push: | |
tags: | |
- 'v*' | |
permissions: | |
contents: write | |
jobs: | |
build-windows: | |
runs-on: windows-2022 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install Crystal | |
uses: crystal-lang/install-crystal@v1 | |
with: | |
crystal: 1.13.1 | |
- name: Build SQLite3 static library | |
run: "scripts/sqlite3-static.ps1" | |
- name: Install shards dependencies | |
run: shards install --production | |
- name: Build coverage reporter CLI | |
run: crystal build src\cli.cr -o dist\coveralls --release --static --no-debug --progress | |
- name: Prepare distribution archive | |
run: | | |
cd dist | |
$vsbase = vswhere.exe -products * -property installationPath -latest | |
if (-not $vsbase) { | |
Write-Error "Visual Studio installation not found" | |
exit 1 | |
} | |
$dumpbinPath = Join-Path $vsbase "VC\Tools\MSVC\*\bin\HostX64\x64\dumpbin.exe" | |
$resolvedDumpbin = Get-Item $dumpbinPath | Select-Object -First 1 | |
if (-not $resolvedDumpbin) { | |
Write-Error "dumpbin.exe not found" | |
exit 1 | |
} | |
& $resolvedDumpbin /dependents coveralls.exe | |
tar -acf coveralls-windows.zip coveralls.exe | |
- name: Upload exe | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coveralls-windows.exe | |
path: dist/coveralls.exe | |
if-no-files-found: error | |
- name: Upload zip | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coveralls-windows.zip | |
path: dist/coveralls-windows.zip | |
if-no-files-found: error | |
build-linux: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Docker BuildX | |
run: | | |
docker run --rm --privileged docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64 | |
docker buildx create --use | |
- name: Build multi-architecture binaries | |
run: | | |
docker buildx build \ | |
--platform linux/amd64,linux/arm64 \ | |
--build-arg CRYSTAL_VERSION=1.13.1 \ | |
--output type=local,dest=dist/ . | |
- name: (Debug) Inspect dist directory contents | |
run: | | |
echo "Listing contents of dist directory:" | |
ls -R dist | |
- name: (Debug) Search for coveralls binary in dist directory | |
run: | | |
echo "Searching for coveralls binary in dist directory:" | |
find dist -type f -name 'coveralls' -exec ls -l {} \; | |
- name: Rename and prepare artifacts | |
run: | | |
cd dist | |
mv linux_amd64/app/coveralls coveralls-x86_64 | |
mv linux_arm64/app/coveralls coveralls-aarch64 | |
tar -czf coveralls-x86_64.tar.gz coveralls-x86_64 | |
tar -czf coveralls-aarch64.tar.gz coveralls-aarch64 | |
- name: Upload binaries and archives | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coveralls-x86_64 | |
path: dist/coveralls-x86_64 | |
if-no-files-found: error | |
- name: Upload tar.gz archives | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coveralls-x86_64.tar.gz | |
path: dist/coveralls-x86_64.tar.gz | |
if-no-files-found: error | |
- name: Upload ARM binaries and archives | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coveralls-aarch64 | |
path: dist/coveralls-aarch64 | |
if-no-files-found: error | |
- name: Upload ARM tar.gz archives | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coveralls-aarch64.tar.gz | |
path: dist/coveralls-aarch64.tar.gz | |
if-no-files-found: error | |
release: | |
runs-on: ubuntu-latest | |
needs: [build-windows, build-linux] | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Fetch tags | |
run: git fetch --force --tags | |
- uses: actions/download-artifact@v3 | |
with: | |
path: artifacts/ | |
- name: Prepare files for release | |
run: | | |
mkdir release/ | |
find artifacts/ -type f -exec cp \{} release/ \; | |
cd release/ | |
mv coveralls-x86_64 coveralls-linux-x86_64 | |
mv coveralls-aarch64 coveralls-linux-aarch64 | |
mv coveralls.exe coveralls-windows.exe | |
sha256sum * > coveralls-checksums.txt | |
- name: Create Github release | |
env: | |
TAG: ${{ github.ref }} | |
GH_TOKEN: ${{ github.token }} | |
run: > | |
cd release/; | |
gh release create ${TAG} | |
'coveralls-linux-x86_64#coveralls-linux-x86_64' | |
'coveralls-linux-x86_64.tar.gz#coveralls-linux-x86_64.tar.gz' | |
'coveralls-linux-aarch64#coveralls-linux-aarch64' | |
'coveralls-linux-aarch64.tar.gz#coveralls-linux-aarch64.tar.gz' | |
'coveralls-windows.exe#coveralls-windows.exe' | |
'coveralls-windows.zip#coveralls-windows.zip' | |
'coveralls-checksums.txt#coveralls-checksums.txt' | |
--generate-notes | |
homebrew: | |
runs-on: ubuntu-latest | |
needs: [release] | |
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') | |
steps: | |
- name: Update Homebrew formula | |
uses: dawidd6/action-homebrew-bump-formula@v3 | |
with: | |
tap: coverallsapp/coveralls | |
formula: coveralls | |
token: ${{ secrets.HOMEBREW_TOKEN }} |