wstunnel/.github/workflows/release.yaml
Σrebe - Romain GERARD a578fbbe27 Add github action
Former-commit-id: 48179cefd4cfe195ca8be5e40a8fe84f68240f05 [formerly d84e1bd5c214d231f01b6728cc6d26aa5fbdeb09] [formerly 896de156e6e9e8ed8bc10a57b7d14e63fab0c5be [formerly 965588646b529458fcdef84cf183a2fd076a9e46]]
Former-commit-id: b94bd4fd284b2b1e6c422a0a473db979c0009378 [formerly 6dcbfbe415c9b1a553a33837c30f15433a4d8df6]
Former-commit-id: f94d3958d641f76e7b9b16a19d067b6893f9aea5
Former-commit-id: 602e02b90e21a73232492e4cecbb39006c478e70
Former-commit-id: 1c380ea7174f475197d7dba7dfb5057d7d296235
Former-commit-id: 2c61c3ec0cf69314eeadc8fdf804b43f598d2e82 [formerly 5d3c3043a947b543e4ab61397174ff3056e6c7cb]
Former-commit-id: 024e4781d496500c9961017a8caafc4e42b83aa4
2023-10-15 18:40:24 +02:00

108 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
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