Native Library Builder #97
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: Native Library Builder | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| build_native: | |
| name: Cross build with Scala Native | |
| permissions: write-all | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| arch: x64 | |
| name: linux | |
| # TODO This works, but binary signing and notarization is required | |
| - os: macos-latest | |
| arch: arm64 | |
| name: mac | |
| # TODO It seems arm64 is not available yet (2024-11) | |
| - os: ARM64 | |
| arch: arm64 | |
| name: linux | |
| # TODO Need some tweaks to run sbt on Windows | |
| # - os: windows-latest | |
| # arch: x64 | |
| # name: windows | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: wvlet/wvlet | |
| - uses: actions/checkout@v4 | |
| with: | |
| path: local | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '23' | |
| cache: sbt | |
| - name: Set SCALA_VERSION env | |
| run: | | |
| SCALA_VERSION=$(cat SCALA_VERSION) | |
| echo SCALA_VERSION: $SCALA_VERSION | |
| echo "SCALA_VERSION=$SCALA_VERSION" >> $GITHUB_ENV | |
| - name: Atomic Libs | |
| if: ${{ matrix.name == 'linux' && matrix.arch == 'arm64' }} | |
| run: apt install -y libatomic1 | |
| - name: Build native libraries for ${{ matrix.name }}-${{ matrix.arch }} | |
| run: | | |
| ./sbt 'wvcLib/nativeLink' | |
| ./sbt 'wvcLibStatic/nativeLink' | |
| FILEPATH=$(find . -name 'libwvlet.*') | |
| echo "Found $FILEPATH" | |
| mkdir -p out | |
| cp $FILEPATH ./out/ | |
| cd ./out && for f in *.*; do mv -- "$f" "${{ matrix.name }}-${{ matrix.arch }}_$f"; done | |
| ls -alFh | |
| - name: Repack aarch64 w/ atomic | |
| if: ${{ matrix.name == 'linux' && matrix.arch == 'arm64' }} | |
| run: | | |
| LIBATOMIC_PATH=$(find /usr -name "libatomic.a" 2>/dev/null | head -n 1) | |
| mkdir ./tmplib | |
| cp ./out/linux-arm64_libwvlet.a ./tmplib/ | |
| cp $LIBATOMIC_PATH ./tmplib/ | |
| cd ./tmplib | |
| ar -x libatomic.a | |
| ar -x linux-arm64_libwvlet.a | |
| ar -r libcombined.a *.o | |
| rm *.o | |
| mv libcombined.a ../out/linux-arm64_libwvlet.a | |
| - name: Upload native libraries for ${{ matrix.name }}-${{ matrix.arch }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: libwvlet_${{ matrix.name }}-${{ matrix.arch }} | |
| path: ./out/*.* | |
| - name: Upload libraries to release | |
| if: github.event_name == 'release' | |
| uses: svenstaro/upload-release-action@v2 | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: ./out/*.* | |
| tag: ${{ github.ref }} | |
| overwrite: true | |
| file_glob: true | |
| collect_artifact: | |
| name: Collect wvc binaries | |
| runs-on: ubuntu-latest | |
| needs: build_native | |
| steps: | |
| - name: Merge artifacts | |
| uses: actions/upload-artifact/merge@v4 | |
| with: | |
| name: wvc-binaries | |
| delete-merged: true |