7e31fcaa68
Former-commit-id: ecf6c08d3b07c33486739c0dbdbe92b94fa95d79 [formerly 86bdb695c6dad79692ad0bf6a3f0943c95e4d54a] [formerly e976b43497ccda52960ba00a2c39214e851e2e9f [formerly 28da84974c059fca8ff4c109b3c090cb72d0c5f6]] Former-commit-id: 40656a9041dcb577589bf4a6cfbb0c9c417b0a7e [formerly 05fd2a954fa10612e20c3c0056b844a8027188d8] Former-commit-id: 374d916d46a57846c77df0ea67e4990c0b915736 Former-commit-id: c306cc94593b0428dd3b2acffdd3e30ddd1e27d0 Former-commit-id: 091c84f544ec82f979b4e07c3cff2266f1305f3b Former-commit-id: dc78fc2935e81c6674e80a6c63434b2af097aaef [formerly 9c16de20c26bb45173c1ae5be9a864342a16a749] Former-commit-id: 7523381366fb394b5fc7aa062306fd69cd50266c
109 lines
3.5 KiB
YAML
109 lines
3.5 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: Create annotation for build error
|
|
if: contains(matrix.platform.target, 'linux')
|
|
run: sudo apt install musl-tools
|
|
|
|
- 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
|