wstunnel/.github/workflows/release.yaml
Σrebe - Romain GERARD c9ec00b975 Bump
Former-commit-id: d044cbb1118c6a46e101d127bc914a6868600c21 [formerly 81ebab557abb1346b856105cf45594b827cb96e0] [formerly 310a36d58ac56a0caf13a43bb6b4bd130afbcd9f [formerly 35bc79eb615d627824b6ff1d87b7ea2ef9be58e8]]
Former-commit-id: 16a9ca0665cecd7dc2e4133bb478ffe65683408c [formerly 18e28a2de9681679d2a8550785a2eb88f6bc6452]
Former-commit-id: 70a437791f593ca56694c17867ba8004fcf48138
Former-commit-id: 46ad8a72d89a9c526975afb3f5c1189a2fc9fe90
Former-commit-id: 5414411d23e6ecbb79a5466c29d3073835dba1a2
Former-commit-id: 69de535552b06cb18e69ef7f6028e437b87827a1 [formerly 72586922fbaf8525a881e155e925d47a7601b27c]
Former-commit-id: c2a7019a3f2d46f69179549f317ca407b9c6dc6f
2023-10-18 17:45:47 +02:00

131 lines
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
#- 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: ${{ 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
- name: list artifacts
run: ls artifacts/*
# Goreleaser
- name: Set up Go
uses: actions/setup-go@v4
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
# Run goreleaser and ignore non-committed files (downloaded artifacts)
args: release --clean --skip=validate
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}