use statically build libraries instead of syso files #2
Workflow file for this run
This file contains hidden or 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 Static Libraries | |
on: | |
workflow_dispatch: # Manual trigger | |
push: | |
paths: | |
- 'src/**' | |
- '.github/workflows/build-static-libs.yml' | |
pull_request: | |
paths: | |
- 'src/**' | |
jobs: | |
build-linux-amd64: | |
runs-on: ubuntu-20.04 # Older Ubuntu for better compatibility | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential | |
- name: Build Linux AMD64 library | |
run: | | |
cd src | |
make clean | |
# Build with maximum compatibility flags | |
CFLAGS="-O3 -Wall -Werror -static -fno-stack-protector -fno-plt" make libhashtree.a | |
- name: Upload Linux AMD64 library | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libhashtree-linux-amd64 | |
path: build/lib/libhashtree.a | |
retention-days: 7 | |
build-linux-arm64: | |
runs-on: ubuntu-20.04 # Older Ubuntu for better compatibility | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install ARM64 cross-compiler | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gcc-aarch64-linux-gnu | |
- name: Build Linux ARM64 library | |
run: | | |
cd src | |
make clean | |
# Build with maximum compatibility flags | |
CC=aarch64-linux-gnu-gcc ARM=1 CFLAGS="-O3 -Wall -Werror -static -fno-stack-protector -fno-plt" make libhashtree.a | |
- name: Upload Linux ARM64 library | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libhashtree-linux-arm64 | |
path: build/lib/libhashtree.a | |
retention-days: 7 | |
build-darwin-amd64: | |
runs-on: macos-13 # Intel-based macOS | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build Darwin AMD64 library | |
run: | | |
cd src | |
make clean | |
# Build with compatibility flags for older macOS | |
CFLAGS="-O3 -Wall -Werror -mmacosx-version-min=10.13" make libhashtree.a | |
- name: Upload Darwin AMD64 library | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libhashtree-darwin-amd64 | |
path: build/lib/libhashtree.a | |
retention-days: 7 | |
build-darwin-arm64: | |
runs-on: macos-14 # Apple Silicon macOS | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build Darwin ARM64 library | |
run: | | |
cd src | |
make clean | |
# Build with compatibility flags for older macOS (ARM64 minimum) | |
CFLAGS="-O3 -Wall -Werror -mmacosx-version-min=11.0" make libhashtree.a | |
- name: Upload Darwin ARM64 library | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libhashtree-darwin-arm64 | |
path: build/lib/libhashtree.a | |
retention-days: 7 | |
build-windows-amd64: | |
runs-on: windows-latest | |
defaults: | |
run: | |
shell: msys2 {0} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup MSYS2 | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: MINGW64 | |
update: true | |
install: >- | |
mingw-w64-x86_64-gcc | |
mingw-w64-x86_64-make | |
make | |
- name: Build Windows AMD64 library | |
run: | | |
cd src | |
make clean | |
# Build with compatibility flags | |
CFLAGS="-O3 -Wall -Werror -static" make libhashtree.a | |
- name: Upload Windows AMD64 library | |
uses: actions/upload-artifact@v4 | |
with: | |
name: libhashtree-windows-amd64 | |
path: build/lib/libhashtree.a | |
retention-days: 7 | |
collect-libraries: | |
runs-on: ubuntu-latest | |
needs: [build-linux-amd64, build-linux-arm64, build-darwin-amd64, build-darwin-arm64, build-windows-amd64] | |
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main') | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create lib directories | |
run: | | |
mkdir -p lib/{linux_amd64,linux_arm64,darwin_amd64,darwin_arm64,windows_amd64} | |
- name: Download all libraries | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: libhashtree-* | |
merge-multiple: false | |
- name: Move libraries to correct locations | |
run: | | |
cp libhashtree-linux-amd64/libhashtree.a lib/linux_amd64/ | |
cp libhashtree-linux-arm64/libhashtree.a lib/linux_arm64/ | |
cp libhashtree-darwin-amd64/libhashtree.a lib/darwin_amd64/ | |
cp libhashtree-darwin-arm64/libhashtree.a lib/darwin_arm64/ | |
cp libhashtree-windows-amd64/libhashtree.a lib/windows_amd64/ | |
- name: Verify libraries | |
run: | | |
echo "Linux AMD64:" && file lib/linux_amd64/libhashtree.a | |
echo "Linux ARM64:" && file lib/linux_arm64/libhashtree.a | |
echo "Darwin AMD64:" && file lib/darwin_amd64/libhashtree.a | |
echo "Darwin ARM64:" && file lib/darwin_arm64/libhashtree.a | |
echo "Windows AMD64:" && file lib/windows_amd64/libhashtree.a | |
- name: Commit updated libraries | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add lib/ | |
if ! git diff --staged --quiet; then | |
git commit -m "Update pre-built static libraries | |
Built from commit ${{ github.sha }} | |
🤖 Generated with GitHub Actions" | |
git push | |
else | |
echo "No changes to libraries" | |
fi |