1c2284ea42
Former-commit-id: 107289b39e8404e6178cc6447bc0511c47b3f4f0 [formerly a9651e1cbfb73ac8dc193ba869cf27aeb8d768e9] [formerly a3900c268b4af76464c8c28cc0f6ed34fbf96f2e [formerly ac3955200a10f0d3dc94faba8f4b8d2d6d068799]] Former-commit-id: 8f2b7b1ab0b33bc148313db619059e4e9be19e31 [formerly 535064df9627acd1dd41421f61736877c8c617c4] Former-commit-id: 503142531791ea9c6c29c941aab594a6c7fa0bb7 Former-commit-id: cc25405df1afc780654814fac77f07ea89ae9039 Former-commit-id: db3c720e5dd8a03428fcd8fb1e62a5f6cee97bb5 Former-commit-id: c4002ab101daa33a9e9b31d084ad5d3d3d38c6ac [formerly 234a0226d829e21e26da9af8208837d1440db025] Former-commit-id: c421a970f46a7bd622df67f7dc93b20219e9da7c
105 lines
3.4 KiB
YAML
105 lines
3.4 KiB
YAML
on:
|
|
# Indicates I want to run this workflow on all branches, PR, and tags
|
|
push:
|
|
branches: ["neo"]
|
|
tags: ["*"]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
env:
|
|
RUST_VERSION: 1.73.0
|
|
BUILD_ARGS: "--release"
|
|
BIN_NAME: "wstunnel"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build - ${{ matrix.platform.name }}
|
|
# By default, runs on Ubuntu, otherwise, override with the desired os
|
|
runs-on: ${{ matrix.platform.os || 'ubuntu-22.04' }}
|
|
strategy:
|
|
matrix:
|
|
# Set platforms you want to build your binaries on
|
|
platform:
|
|
# Linux
|
|
- name: Linux x86_64
|
|
target: x86_64-unknown-linux-musl
|
|
|
|
- name: Linux aarch64
|
|
target: aarch64-unknown-linux-musl
|
|
|
|
- name: Linux armv7hf
|
|
target: armv7-unknown-linux-musleabihf
|
|
|
|
# Mac OS
|
|
# - name: MacOS x86_64
|
|
# target: x86_64-apple-darwin
|
|
# - name: MacOS aarch64
|
|
# target: aarch64-apple-darwin
|
|
|
|
# Windows
|
|
- name: Windows x86_64
|
|
# Use another GitHub action OS
|
|
os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
|
|
steps:
|
|
- name: Checkout Git repo
|
|
uses: actions/checkout@v3
|
|
|
|
# Linux & Windows
|
|
- name: Install rust toolchain
|
|
if: ${{ !contains(matrix.platform.target, 'apple') }}
|
|
uses: actions-rs/toolchain@v1
|
|
with:
|
|
# We setup Rust toolchain and the desired target
|
|
profile: minimal
|
|
toolchain: "${{ env.RUST_VERSION }}"
|
|
override: true
|
|
target: ${{ matrix.platform.target }}
|
|
components: rustfmt, clippy
|
|
- name: Build ${{ matrix.platform.name }} binary
|
|
if: ${{ !contains(matrix.platform.target, 'apple') }}
|
|
uses: actions-rs/cargo@v1
|
|
# We use cross-rs if not running on x86_64 architecture on Linux
|
|
with:
|
|
command: build
|
|
use-cross: ${{ !contains(matrix.platform.target, 'x86_64') }}
|
|
args: ${{ env.BUILD_ARGS }} --target ${{ matrix.platform.target }}
|
|
|
|
# Mac OS
|
|
- name: Login to DockerHub
|
|
if: contains(matrix.platform.target, 'apple')
|
|
# We log on DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ env.DOCKER_LOGIN }}
|
|
password: ${{ env.DOCKER_TOKEN }}
|
|
- name: Build ${{ matrix.platform.name }} binary
|
|
if: contains(matrix.platform.target, 'apple')
|
|
# We use a dedicated Rust image containing required Apple libraries to cross-compile on multiple archs
|
|
run: |
|
|
docker run --rm --volume "${PWD}":/root/src --workdir /root/src joseluisq/rust-linux-darwin-builder:$RUST_VERSION \
|
|
sh -c "CC=o64-clang CXX=o64-clang++ cargo build $BUILD_ARGS --target ${{ matrix.platform.target }}"
|
|
|
|
- name: Store artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
# Finally, we store the binary as GitHub artifact for later usage
|
|
name: ${{ matrix.platform.target }}-${{ env.BIN_NAME }}
|
|
path: target/${{ matrix.platform.target }}/release/${{ env.BIN_NAME }}${{ contains(matrix.platform.target, 'windows') && '.exe' || '' }}
|
|
retention-days: 1
|
|
|
|
release:
|
|
name: Release
|
|
needs: [build]
|
|
# We run the release job only if a tag starts with 'v' letter
|
|
if: startsWith( github.ref, 'refs/tags/v' )
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout Git repo
|
|
uses: actions/checkout@v3
|
|
|
|
# Download all artifacts
|
|
- uses: actions/download-artifact@v3
|
|
with:
|
|
path: artifacts
|