linux-arm: build #117
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: | |
push: | |
# TODO: debug | |
# tags: | |
# - v* | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
build: | |
# TODO: | |
# - target: x86_64-apple-darwin | |
# os: macos-latest | |
# - target: aarch64-apple-darwin | |
# os: macos-latest | |
# - target: x86_64-unknown-linux-musl | |
# os: ubuntu-latest | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
# TODO: | |
# - target: x86_64-pc-windows-msvc | |
# os: windows-latest | |
# - target: aarch64-pc-windows-msvc | |
# os: windows-latest | |
runs-on: ${{ matrix.build.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install target | |
run: rustup target add ${{ matrix.build.target }} | |
- name: Setup musl | |
run: sudo apt-get install -y musl-tools | |
if: endsWith(matrix.build.target, '-musl') | |
- name: Setup aarch64 linux | |
run: sudo apt-get install -y gcc-aarch64-linux-gnu | |
if: matrix.build.target == 'aarch64-unknown-linux-musl' | |
- name: Setup windows | |
run: | | |
# setup perl for bash shell https://github.com/sfackler/rust-openssl/issues/2149#issuecomment-2014064057 | |
echo "PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
echo "OPENSSL_SRC_PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
if: runner.os == 'Windows' | |
- uses: Swatinem/rust-cache@v2 | |
- name: Build | |
env: | |
TARGET: ${{ matrix.build.target }} | |
shell: bash | |
run: | | |
# TODO: move | |
export CC=aarch64-linux-gnu-gcc | |
declare output | |
output="$( | |
cargo build \ | |
--workspace \ | |
--release \ | |
--target "$TARGET" \ | |
--message-format=json \ | |
| jq -r '.message.rendered // .executable // empty' | |
)" || { | |
declare exit_code="$?" | |
echo "$output" | |
exit "$exit_code" | |
} | |
{ | |
echo 'ARTIFACT_PATHS<<EOF' | |
echo "$output" | |
echo 'EOF' | |
} >> "$GITHUB_ENV" | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.build.target }} | |
path: ${{ env.ARTIFACT_PATHS }} | |
if-no-files-found: error | |
release: | |
name: Release | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
- name: Create Release | |
env: | |
GITHUB_USER: ${{ github.repository_owner }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
mkdir assets | |
# move binaries to assets directory | |
for path in artifacts/*; do | |
declare artifact="$(basename "$path")" | |
mv "${path}/nk"* "assets/${artifact}" | |
done | |
# create release | |
gh release create \ | |
--title "$GITHUB_REF_NAME" \ | |
--notes '' \ | |
"$GITHUB_REF_NAME" \ | |
"assets/"* |