-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d44916
commit 4dd6593
Showing
1 changed file
with
89 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Rust | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
RELEASE_BIN: favicon | ||
RELEASE_DIR: artifacts | ||
CARGO_TERM_COLOR: always | ||
GITHUB_REF: '${{ github.ref }}' | ||
WINDOWS_TARGET: x86_64-pc-windows-msvc | ||
MACOS_TARGET: x86_64-apple-darwin | ||
MACOS_SILICON_TARGET: aarch64-apple-darwin | ||
LINUX_AMD64_TARGET: x86_64-unknown-linux-musl | ||
LINUX_ARM64_TARGET: aarch64-unknown-linux-musl | ||
|
||
jobs: | ||
build: | ||
name: Build artifacts | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- target: x86_64-unknown-linux-musl | ||
os: ubuntu-latest | ||
rust: stable | ||
- target: aarch64-unknown-linux-musl | ||
os: ubuntu-latest | ||
rust: stable | ||
- target: x86_64-apple-darwin | ||
os: macos-latest | ||
rust: stable | ||
- target: aarch64-apple-darwin | ||
os: macos-latest | ||
rust: stable | ||
- target: x86_64-pc-windows-msvc | ||
os: windows-latest | ||
rust: stable | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install C compilation tooling (Linux) | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get update -y | ||
sudo apt-get install clang gcc-aarch64-linux-gnu -y | ||
echo "TARGET_CC=clang" >> $GITHUB_ENV | ||
echo "CFLAGS_aarch64_unknown_linux_musl=--sysroot=/usr/aarch64-linux-gnu" >> $GITHUB_ENV | ||
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=/usr/aarch64-linux-gnu/bin/ld" >> $GITHUB_ENV | ||
- name: Install p7zip (MacOS) | ||
if: matrix.os == 'macos-latest' | ||
run: brew install p7zip | ||
|
||
- name: Add rustup target | ||
run: rustup target add ${{ matrix.target }} | ||
- name: Build | ||
run: cargo build --release --target ${{ matrix.target }} | ||
- name: Set RUSTFLAGS (Windows) | ||
if: matrix.os == 'windows-latest' | ||
run: echo "RUSTFLAGS=-Ctarget-feature=+crt-static" >> $GITHUB_ENV | ||
|
||
- name: Create artifact directory | ||
run: | | ||
mkdir ${{ env.RELEASE_DIR }} | ||
mkdir -p ${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }} | ||
- name: Move binaries (Linux/MacOS) | ||
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' | ||
run: | | ||
mv ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}/${{ env.RELEASE_BIN }} | ||
mv ${{ env.RELEASE_ADDS }} ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }} | ||
- name: Move binaries (Windows) | ||
if: matrix.os == 'windows-latest' | ||
shell: bash | ||
run: | | ||
cp ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }}.exe ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}/${{ env.RELEASE_BIN }}.exe | ||
mv ${{ env.RELEASE_ADDS }} ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }} | ||
- name: Create tarball | ||
shell: bash | ||
run: 7z a -ttar -so -an ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }} | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.tar.gz | ||
|
||
- name: Upload Zip | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: ${{ matrix.target }} | ||
path: ./${{ env.RELEASE_DIR }} | ||
|