wstunnel/.github/workflows/release.yaml
Σrebe - Romain GERARD 28f04a1d0b Add go-releaser
Former-commit-id: dabd50c07b1c6be914d9983a4bd9dfc547e1dfb8 [formerly 78b93809d9a27f141dc8cb055dac314a41004e12] [formerly 7487c53142eccfda7831f64a0151733a19945f35 [formerly ed370bab3fa1fea9f5384f73424ae199e0926acb]]
Former-commit-id: 8a68e7be2747e2b3f858aca72d43c214ed05a669 [formerly 4b817e8ac0cee86c28b3446a7ca8e0a2055d656a]
Former-commit-id: 55e5c3f430f581a945ff579c30266290f2771062
Former-commit-id: 6492e42461c35657c0c3737da1ee3533e5a37287
Former-commit-id: a69a6a5219e66294925fcb19eb4f936f448fd1dd
Former-commit-id: 5e8491f9b02e6fd666f125ad177d80821cd04468 [formerly 216578e43468ff3d3ce486a2c4432caf0c64ec55]
Former-commit-id: 441f0b4513e666787fa34e47cc85d9dce3ad6d3f
2023-10-18 15:28:45 +02:00

128 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
# 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 }}