Add github action
Former-commit-id: b4107cc65ab53fe34f486bba2bd2ab24a2f532ff [formerly c71b6e15f242973f6a9392f77e0142dd630a4976] [formerly fd687cfdc477988e055ff64a30b57c2f1bcc07a5 [formerly 77475b0d3cb7929fcef27c43b3608c8e2bb5206a]] Former-commit-id: 69b63e44147af1743d6b66dc572848029739305d [formerly 832d751e69bbde183a444f6e859cfa995f1ae222] Former-commit-id: 86fc12f4a5fe15747ed6aa8217b88cfb2f4b36f0 Former-commit-id: 84630c7fe92e83e039a61b4e1af0cc0a9fc28128 Former-commit-id: 7908d1dde874da807b9465360b966fd0df2f2288 Former-commit-id: 4d75214ab2722075195fc8fe779d3f524c3f0ed9 [formerly 33d8550184c6e80eafcacc948e0b6428084725dc] Former-commit-id: 1eed52ba1c2c544fded3a0f36def6741198e6e83
This commit is contained in:
parent
8387557459
commit
2a3c0f249a
1 changed files with 105 additions and 0 deletions
105
.github/workflows/release.yaml
vendored
Normal file
105
.github/workflows/release.yaml
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
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: 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
|
Loading…
Reference in a new issue