forked from angelofallars/treefetch
-
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
Showing
1 changed file
with
253 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,253 @@ | ||
name: Rust Build by cross and release | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
env: | ||
CRATE_NAME: freshfetch | ||
GITHUB_TOKEN: ${{ github.token }} | ||
RUST_BACKTRACE: 1 | ||
|
||
|
||
jobs: | ||
test: | ||
permissions: write-all | ||
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }} | ||
runs-on: ${{ matrix.platform.os }} | ||
strategy: | ||
matrix: | ||
platform: | ||
# Platforms that don't work: | ||
# | ||
# - sparc64-unknown-linux-gnu - cannot compile openssl-sys | ||
# - x86_64-unknown-illumos - weird error compiling openssl - "bin/sh: 1: granlib: not found" | ||
# - x86_64-unknown-redox - linking with `cc` failed | ||
# - wasm32 - Only features sync,macros,io-util,rt,time are supported on wasm. | ||
# TEST: | ||
|
||
- os_name: Linux-x86_64-musl | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-musl | ||
bin: ${{ github.event.repository.name }} | ||
name: ${{ github.event.repository.name }}-x86_64-unknown-linux-musl.tar.gz | ||
|
||
- os_name: Linux-x86_64-gnu | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-gnu | ||
bin: ${{ github.event.repository.name }} | ||
name: ${{ github.event.repository.name }}-x86_64-unknown-linux-gnu.tar.gz | ||
|
||
- os_name: Linux-aarch64 | ||
os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-gnu | ||
bin: ${{ github.event.repository.name }} | ||
name: ${{ github.event.repository.name }}-aarch64-unknown-linux-gnu.tar.gz | ||
|
||
# - os_name: Linux-arm-musleabi | ||
# os: ubuntu-20.04 | ||
# target: arm-unknown-linux-musleabi | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-arm-unknown-linux-musleabi.tar.gz | ||
|
||
# - os_name: Linux-arm-gnueabihf | ||
# os: ubuntu-20.04 | ||
# target: arm-unknown-linux-gnueabihf | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-arm-unknown-linux-gnueabihf.tar.gz | ||
|
||
- os_name: armv7-unknown-linux-gnueabi | ||
os: ubuntu-20.04 | ||
target: armv7-unknown-linux-gnueabi | ||
bin: ${{ github.event.repository.name }} | ||
name: ${{ github.event.repository.name }}-armv7-unknown-linux-gnueabi.tar.gz | ||
|
||
- os_name: Linux-armv7-musleabi | ||
os: ubuntu-20.04 | ||
target: armv7-unknown-linux-musleabi | ||
bin: ${{ github.event.repository.name }} | ||
name: ${{ github.event.repository.name }}-armv7-unknown-linux-musleabi.tar.gz | ||
|
||
# - os_name: Linux-i686-musl | ||
# os: ubuntu-20.04 | ||
# target: i686-unknown-linux-musl | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-i686-unknown-linux-musl.tar.gz | ||
# skip_tests: true | ||
|
||
# - os_name: Linux-riscv64 | ||
# os: ubuntu-20.04 | ||
# target: riscv64gc-unknown-linux-gnu | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-riscv64gc-unknown-linux-gnu.tar.gz | ||
|
||
# - os_name: FreeBSD-x86_64 | ||
# os: ubuntu-20.04 | ||
# target: x86_64-unknown-freebsd | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-x86_64-unknown-freebsd.tar.gz | ||
# skip_tests: true | ||
|
||
# - os_name: NetBSD-x86_64 | ||
# os: ubuntu-20.04 | ||
# target: x86_64-unknown-netbsd | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-x86_64-unknown-netbsd.tar.gz | ||
# skip_tests: true | ||
|
||
# - os_name: Windows-x86_64 | ||
# os: windows-latest | ||
# target: x86_64-pc-windows-msvc | ||
# bin: ${{ github.event.repository.name }}.exe | ||
# name: ${{ github.event.repository.name }}-x86_64-pc-windows-msvc.zip | ||
|
||
# - os_name: Windows-aarch64 | ||
# os: windows-latest | ||
# target: aarch64-pc-windows-msvc | ||
# bin: ${{ github.event.repository.name }}.exe | ||
# name: ${{ github.event.repository.name }}-aarch64-pc-windows-msvc.zip | ||
# skip_tests: true | ||
|
||
# - os_name: Windows-i686 | ||
# os: windows-latest | ||
# target: i686-pc-windows-msvc | ||
# bin: ${{ github.event.repository.name }}.exe | ||
# name: ${{ github.event.repository.name }}-i686-pc-windows-msvc-i686.zip | ||
# skip_tests: true | ||
|
||
# - os_name: macOS-x86_64 | ||
# os: macos-12 | ||
# target: x86_64-apple-darwin | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-macOS-x86_64-apple-darwin.tar.gz | ||
|
||
# - os_name: macOS-aarch64 | ||
# os: macos-12 | ||
# target: aarch64-apple-darwin | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-macOS-aarch64-apple-darwin.tar.gz | ||
# skip_tests: true | ||
|
||
# - os_name: IOS-aarch64 | ||
# os: macos-12 | ||
# target: aarch64-apple-ios | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-Apple-aarch64-apple-ios.tar.gz | ||
# skip_tests: true | ||
|
||
# - os_name: aarch64-linux-android | ||
# os: ubuntu-22.04 | ||
# target: aarch64-linux-android | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-aarch64-linux-android.tar.gz | ||
|
||
# - os_name: Android-ARMv7a | ||
# os: ubuntu-22.04 | ||
# target: armv7-linux-androideabi | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-armv7-linux-androideabi.tar.gz | ||
|
||
# - os_name: Android-ARMv7 | ||
# os: ubuntu-22.04 | ||
# target: arm-linux-androideabi | ||
# bin: ${{ github.event.repository.name }} | ||
# name: ${{ github.event.repository.name }}-arm-linux-androideabi.tar.gz | ||
|
||
toolchain: | ||
- stable | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Cache cargo & target directories | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install musl-tools on Linux | ||
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools | ||
if: contains(matrix.platform.name, 'musl') | ||
|
||
- name: Install libunwind8-dev for Android | ||
run: sudo apt-get update --yes && sudo apt-get install --yes android-libunwind-dev | ||
if: contains(matrix.platform.target, 'aarch64-linux-android') | ||
|
||
- name: Build binary | ||
uses: houseabsolute/actions-rust-cross@v0 | ||
with: | ||
command: "build" | ||
target: ${{ matrix.platform.target }} | ||
toolchain: ${{ matrix.toolchain }} | ||
args: "--release" | ||
strip: true | ||
if: | | ||
matrix.toolchain == 'stable' && | ||
contains(matrix.platform.target, 'aarch64-linux-android') == false && | ||
( startsWith( github.ref, 'refs/tags/v' ) || | ||
github.ref == 'refs/tags/test-release' ) | ||
- name: Build binary for aarch64-linux-android | ||
shell: bash | ||
run: | | ||
rustup target add aarch64-linux-android | ||
# Adapted from https://github.com/briansmith/ring/blob/main/mk/cargo.sh | ||
set -eux -o pipefail | ||
OS_NAME=$(uname -s | tr A-Z a-z) | ||
# Avoid putting the Android tools in `$PATH` because there are tools in this | ||
# directory like `clang` that would conflict with the same-named tools that may | ||
# be needed to compile the build script, or to compile for other targets. | ||
if [ -n "${ANDROID_HOME-}" ]; then | ||
# Keep the next line in sync with the corresponding line in install-build-tools.sh. | ||
ndk_version=25.2.9519653 | ||
ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT:-${ANDROID_HOME}/ndk/$ndk_version} | ||
fi | ||
if [ -n "${ANDROID_NDK_ROOT-}" ]; then | ||
android_tools=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${OS_NAME}-x86_64/bin | ||
fi | ||
export CC_aarch64_linux_android=$android_tools/aarch64-linux-android21-clang | ||
export AR_aarch64_linux_android=$android_tools/llvm-ar | ||
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$android_tools/aarch64-linux-android21-clang | ||
cargo build --verbose --release --target=aarch64-linux-android | ||
if: | | ||
matrix.toolchain == 'stable' && | ||
contains(matrix.platform.target, 'aarch64-linux-android') && | ||
( startsWith( github.ref, 'refs/tags/v' ) || | ||
github.ref == 'refs/tags/test-release' ) | ||
- name: Package as archive | ||
shell: bash | ||
run: | | ||
echo running archive | ||
cd target/${{ matrix.platform.target }}/release | ||
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then | ||
7z a ../../../${{ matrix.platform.name }} ${{ github.event.repository.name }}.exe | ||
else | ||
tar czvf ../../../${{ matrix.platform.name }} ${{ github.event.repository.name }} | ||
fi | ||
cd - | ||
if: | | ||
matrix.toolchain == 'stable' && | ||
( startsWith( github.ref, 'refs/tags/v' ) || | ||
github.ref == 'refs/tags/test-release' ) | ||
- name: Publish release artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ github.event.repository.name }}-${{ matrix.platform.os_name }} | ||
path: "${{ github.event.repository.name }}-*" | ||
if: matrix.toolchain == 'stable' | ||
|
||
- name: Generate SHA-256 | ||
run: shasum -a 256 ${{ matrix.platform.name }} | ||
if: | | ||
matrix.toolchain == 'stable' && | ||
( startsWith( github.ref, 'refs/tags/v' ) || | ||
github.ref == 'refs/tags/test-release' ) | ||
- name: Publish GitHub release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
files: "${{ github.event.repository.name }}-*" | ||
body_path: Changes.md | ||
if: matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags/v' ) |