1.1.1 #8
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build release | |
on: | |
workflow_dispatch: | |
inputs: | |
chosen_platform: | |
description: "Select the platform" | |
required: true | |
type: choice | |
options: | |
- linux-arm64 | |
- linux-x64 | |
- win-x64 | |
- mac-arm64 | |
release: | |
types: [published] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
name: Build & Release - ${{ matrix.config.platform }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
matrix: | |
config: | |
- { platform: win-x64, os: windows-latest, target: x86_64-pc-windows-msvc } | |
- { platform: mac-arm64, os: macOS-latest, target: aarch64-apple-darwin } | |
- { platform: linux-x64, os: ubuntu-latest, target: x86_64-unknown-linux-gnu } | |
- { platform: linux-arm64, os: ubuntu-latest, target: aarch64-unknown-linux-gnu } | |
environment: PROD | |
env: | |
CARGO_SERVER_SSL_CA: ${{ secrets.SERVER_SSL_CA }} | |
CARGO_SERVER_SSL_CERT: ${{ secrets.SERVER_SSL_CERT }} | |
CARGO_SERVER_SSL_KEY: ${{ secrets.SERVER_SSL_KEY }} | |
FILENAME: tagoio-relay-${{ matrix.config.platform }} | |
steps: | |
# Preparation Steps | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust toolchain and components | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: "${{ matrix.config.target }}" | |
- name: Setup Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Create empty .env file | |
run: touch .env | |
#### | |
## Windows Only Steps | |
#### | |
- name: Install NASM (Windows only) | |
if: matrix.config.os == 'windows-latest' | |
uses: ilammy/setup-nasm@v1 | |
- name: Build Binary (Windows only) | |
if: matrix.config.os == 'windows-latest' | |
uses: houseabsolute/actions-rust-cross@v0 | |
with: | |
command: "build" | |
target: "${{ matrix.config.TARGET }}" | |
toolchain: "stable" | |
args: "--locked --release" | |
strip: true | |
#### | |
# Linux and macOS Steps | |
#### | |
- name: Install cross (Linux ARM64 only) | |
if: matrix.config.target == 'aarch64-unknown-linux-gnu' | |
run: cargo install cross | |
- name: Build Binary (Linux and macOS) | |
if: matrix.config.os != 'windows-latest' | |
run: | | |
if [ "${{ matrix.config.target }}" == "aarch64-unknown-linux-gnu" ]; then | |
cross build --locked --release --target ${{ matrix.config.target }} | |
else | |
cargo build --locked --release --target ${{ matrix.config.target }} | |
fi | |
- name: Run tests | |
if: matrix.config.os != 'windows-latest' | |
run: | | |
if [ "${{ matrix.config.target }}" == "aarch64-unknown-linux-gnu" ]; then | |
cross test --verbose --target ${{ matrix.config.target }} | |
else | |
cargo test --verbose | |
fi | |
# Package the binary for the current OS (zip for Windows, tar.gz for others) | |
- name: Package Binary | |
shell: bash | |
run: | | |
cd target/${{ matrix.config.target }}/release | |
if [ "${{ matrix.config.os }}" == "windows-latest" ]; then | |
7z a ../../../${{ env.filename }}.zip tagoio-relay.exe | |
else | |
tar cvf - tagoio-relay | gzip > ../../../${{ env.FILENAME }}.tar.gz | |
fi | |
# Generate SHA-256 checksum if this is a release (Ignoring windows for now) | |
- name: Generate SHA-256 checksum | |
if: github.event_name == 'release' && matrix.config.os != 'windows-latest' | |
run: shasum -a 256 ${{ env.FILENAME }}.tar.gz > ${{ env.FILENAME }}.tar.gz.sha256 | |
shell: bash | |
# Upload to GitHub Release if this is a release | |
- name: Upload to Release | |
if: github.event_name == 'release' | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
if [ "${{ matrix.config.os }}" == "windows-latest" ]; then | |
./${{ env.FILENAME }}.zip | |
else | |
./${{ env.FILENAME }}.tar.gz | |
./${{ env.FILENAME }}.tar.gz.sha256 | |
fi | |
# Upload artifacts if this is not a release | |
- name: Upload artifact | |
if: github.event_name != 'release' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.FILENAME }} | |
path: | | |
if [ "${{ matrix.config.os }}" == "windows-latest" ]; then | |
./${{ env.FILENAME }}.zip | |
else | |
./${{ env.FILENAME }}.tar.gz | |
fi |