wstunnel/.github/workflows/release.yaml
Σrebe - Romain GERARD 3dfb1b0706 Add github action
Former-commit-id: 09005ee3368bf02cc25817d7d6c3a6fa3acd5280 [formerly c018547ff3cfa0a7020f40769c9798aff6db1a6d] [formerly a29ce289ed4b398094e9179f403e3c23b9709762 [formerly 423b17ee1da769d26b50e47ad353a3f5e986b5c1]]
Former-commit-id: ac5847602f7ccbde4f1f3e3e770b01a0d625f13e [formerly 786faecca9e4831e67e34448ab35c1dadbc4231f]
Former-commit-id: b48d1192af9d9d1373149bd3095b38dd5581d8f7
Former-commit-id: 378b2dce4292267425f738881562bc29a602ef43
Former-commit-id: 1bf57bf462683d30e6094a9625f1635027b06396
Former-commit-id: 07a3412db36659928c83852d876eefddc8e2ed02 [formerly ec17098b366b4cc7a4fd20b8ecb33e08d9e42166]
Former-commit-id: 7b04c5d1b0ddf11fddbe3f75a1288dfbb82822b8
2023-10-15 18:29:41 +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: 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