wstunnel/.github/workflows/release.yaml

181 lines
5.4 KiB
YAML
Raw Permalink Normal View History

on:
# Indicates I want to run this workflow on all branches, PR, and tags
push:
2024-05-25 09:03:17 +00:00
branches: [ "main", "draft" ]
tags: [ "*" ]
pull_request:
branches: [ "main" ]
env:
2024-12-15 08:29:40 +00:00
RUST_VERSION: 1.83.0
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
build-args: "--release"
2024-06-24 18:03:19 +00:00
- name: Linux x86
target: i686-unknown-linux-musl
build-args: "--release"
- name: Linux aarch64
target: aarch64-unknown-linux-musl
build-args: "--release"
- name: Linux armv7hf
target: armv7-unknown-linux-musleabihf
build-args: "--release"
2024-01-22 19:47:55 +00:00
- name: Freebsd x86_64
target: x86_64-unknown-freebsd
build-args: "--release"
2024-01-22 19:47:55 +00:00
- name: Freebsd x86
target: i686-unknown-freebsd
build-args: "--release"
2024-01-22 19:47:55 +00:00
2024-05-25 09:03:17 +00:00
- name: Android aarch64
target: aarch64-linux-android
build-args: "--release"
2023-11-03 08:21:40 +00:00
2024-05-25 09:03:17 +00:00
- name: Android armv7
target: armv7-linux-androideabi
build-args: "--release"
2023-11-03 08:21:40 +00:00
#- name: Linux mips
# target: mips-unknown-linux-musl
#- name: Linux mips64
# target: mips64-unknown-linux-muslabi64
# Mac OS
- name: MacOS x86_64
2023-12-26 18:20:39 +00:00
os: macos-latest
target: x86_64-apple-darwin
build-args: "--release"
2023-12-26 17:59:05 +00:00
- name: MacOS aarch64
2023-12-26 18:20:39 +00:00
os: macos-latest
2023-12-26 17:59:05 +00:00
target: aarch64-apple-darwin
build-args: "--release"
2023-10-28 18:25:54 +00:00
# - name: iOS x86_64
# target: x86_64-apple-ios
2023-10-28 18:25:54 +00:00
#- name: iOS aarch64
# target: aarch64-apple-ios
# Windows
- name: Windows x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
build-args: "--profile release-with-symbols"
2023-11-26 06:55:30 +00:00
- name: Windows x86
os: windows-latest
target: i686-pc-windows-msvc
build-args: "--profile release-with-symbols"
2023-11-26 06:55:30 +00:00
steps:
2024-05-25 09:03:17 +00:00
- name: Install package for linux
if: contains(matrix.platform.target, 'linux')
run: sudo apt install musl-tools
- name: Install package for Android
if: contains(matrix.platform.target, 'android')
2024-05-25 09:22:53 +00:00
run: sudo apt install android-libunwind android-libunwind-dev libunwind-dev
2024-05-25 09:03:17 +00:00
2024-05-25 09:07:15 +00:00
- name: Set up JDK 17
if: contains(matrix.platform.target, 'android')
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
2024-05-25 09:03:17 +00:00
- name: Setup Android SDK
if: contains(matrix.platform.target, 'android')
uses: android-actions/setup-android@v3
- name: Checkout Git repo
uses: actions/checkout@v3
# Linux & Windows
- name: Install rust toolchain for Linux
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
2024-05-25 09:35:06 +00:00
- name: Install package for Android
if: contains(matrix.platform.target, 'android')
run: cargo install cross --git https://github.com/cross-rs/cross
2024-05-25 09:03:17 +00:00
- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.BUILD_ARGS }}"
- name: Build ${{ matrix.platform.name }} binary
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') || contains(matrix.platform.target, 'freebsd') }}
args: ${{ matrix.platform.build-args }} --target ${{ matrix.platform.target }}
- name: Store artifact
2024-09-27 17:35:30 +00:00
uses: actions/upload-artifact@v4
2024-05-25 09:03:17 +00:00
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${{ contains(matrix.platform.target, 'windows') && '-with-symbols' || '' }}/${{ env.BIN_NAME }}${{ contains(matrix.platform.target, 'windows') && '.exe' || '' }}
retention-days: 1
release:
name: Release
2024-05-25 09:03:17 +00:00
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:
2024-05-25 09:03:17 +00:00
- name: Checkout Git repo
uses: actions/checkout@v3
2024-06-07 19:40:28 +00:00
with:
fetch-depth: 0
2024-05-25 09:03:17 +00:00
# Download all artifacts
- uses: actions/download-artifact@v4.1.7
2024-05-25 09:03:17 +00:00
with:
path: artifacts
- name: list artifacts
run: find artifacts/
- name: Set up Go
uses: actions/setup-go@v4
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean --skip=validate
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}