61a11e572e
Former-commit-id: 07e7fbc088c022bcc50c980b4d3991047d4df91c [formerly ec7082255468fa1b1d82c2d3ff89bb6de4f1be6e] [formerly 5e8e1be99044258f1094c322d2f50a650c710871 [formerly 6deaf6bc3844e9dabfe1720d8f9b938f5ac66dc6]] Former-commit-id: 4b6ca604ef39ebdbc08a250340dfb74936a67475 [formerly abe2900f9c7cc1f824b40d7946cc48b7a45fcf45] Former-commit-id: 100b7756ab5d6f8643c2325630c270df913888a7 Former-commit-id: 057566661d93bf057fc3394769c448a50a7032ed Former-commit-id: e02be0e6686cf8bb53a9c90e478d86ca3a112ac4 Former-commit-id: 536b757944aa4822b9a27c6c0b2217ea6898fd27 [formerly d8d16b29ee0064e616bb8c4ca6d7b1163c47b74c] Former-commit-id: 4beceb0f93b5104ac0dadc1ff8746c097591b9a2
146 lines
4.7 KiB
YAML
146 lines
4.7 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 in zip format
|
|
# https://github.com/actions/download-artifact/issues/143
|
|
- name: Download artifacts
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: context.payload.workflow_run.id,
|
|
});
|
|
for (const artifact of allArtifacts.data.artifacts)
|
|
{
|
|
let download = await github.rest.actions.downloadArtifact({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
artifact_id: artifact.id,
|
|
archive_format: 'zip',
|
|
});
|
|
|
|
let fs = require('fs');
|
|
fs.mkdirSync('artifacts');
|
|
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/artifacts/${artifact.name}.zip`, Buffer.from(download.data));
|
|
}
|
|
|
|
- name: list artifacts
|
|
run: find artifacts/
|
|
|
|
- uses: "marvinpinto/action-automatic-releases@latest"
|
|
with:
|
|
repo_token: "${{ secrets.RELEASE_TOKEN }}"
|
|
prerelease: true
|
|
files: |
|
|
artifacts/*
|