wstunnel/.github/workflows/release.yaml
Σrebe - Romain GERARD c641312cf7 update github action
Former-commit-id: c8e121f846c85bbd7332f9804666547c40b5dc29 [formerly 44abc9f7e7cb2693b1b4a806c5e3f7d337e41a37] [formerly aae9fd5d0182d3e0e506372f9900d928fdb1f39f [formerly 80ef014358495404b26be3c1f23a96c84ff09d97]]
Former-commit-id: d3c75ac5a6f3a4364a9d495ac50e8499eef8369c [formerly 34613e42c010b73e69104d51c1f5206de2295b60]
Former-commit-id: 2b4c25d1b80a02e43993acca5884e7b9009a1da2
Former-commit-id: d060a9f4c3697a171dcb8f27391ba26fee6c9b48
Former-commit-id: c6779a73202efb1710bbbe9a52f23210da52aa66
Former-commit-id: 9135d36544b9e47a98002d6dac37a9b5ab0b547f [formerly e25231fdbe764dc77b50b932702a01683ab25a0e]
Former-commit-id: 93fb0be978f7284b337c1183431250f6c6036f62
2023-10-21 19:05:09 +02:00

126 lines
3.8 KiB
YAML

on:
# Indicates I want to run this workflow on all branches, PR, and tags
push:
branches: ["main"]
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
#- name: Linux mips
# target: mips-unknown-linux-musl
#- name: Linux mips64
# target: mips64-unknown-linux-muslabi64
# Mac OS
- name: MacOS x86_64
target: x86_64-apple-darwin
# - name: iOS x86_64
# target: x86_64-apple-ios
#- name: MacOS aarch64
# target: aarch64-apple-darwin
#- name: iOS aarch64
# target: aarch64-apple-ios
# Windows
- name: Windows x86_64
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: 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: ${{ env.BIN_NAME }}-${{ matrix.platform.target }}
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
- name: list artifacts
run: find artifacts/
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.RELEASE_TOKEN }}"
prerelease: true
files: |
artifacts/wstunnel-*/wstunnel