Release Binaries #11
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: Release Binaries | ||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
jobs: | ||
build-release: | ||
name: Build Release | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-musl | ||
artifact_name: rustygate-linux-amd64 | ||
sha_cmd: sha256sum | ||
- os: ubuntu-latest | ||
target: aarch64-unknown-linux-musl | ||
artifact_name: rustygate-linux-arm64 | ||
sha_cmd: sha256sum | ||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
artifact_name: rustygate-darwin-amd64 | ||
sha_cmd: "shasum -a 256" | ||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
artifact_name: rustygate-darwin-arm64 | ||
sha_cmd: "shasum -a 256" | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.target }} | ||
- name: Install dependencies (Ubuntu) | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y musl-tools | ||
sudo apt-get install -y musl-dev | ||
sudo apt-get install -y pkg-config | ||
sudo apt-get install -y libssl-dev | ||
# For aarch64 cross-compilation | ||
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-musl" ]]; then | ||
# Add ARM64 architecture and repositories | ||
sudo dpkg --add-architecture arm64 | ||
sudo sed -i 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list | ||
sudo bash -c 'cat > /etc/apt/sources.list.d/arm64.list << EOL | ||
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy main restricted | ||
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main restricted | ||
deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted | ||
EOL' | ||
sudo apt-get update | ||
sudo apt-get install -y gcc-aarch64-linux-gnu | ||
sudo apt-get install -y libssl-dev:arm64 | ||
fi | ||
# Install OpenSSL dev for MUSL | ||
sudo apt-get install -y musl-dev libssl-dev | ||
sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/ | ||
sudo ln -s /usr/include/openssl /usr/include/x86_64-linux-musl/openssl | ||
- name: Build binary | ||
env: | ||
OPENSSL_STATIC: 1 | ||
PKG_CONFIG_ALLOW_CROSS: 1 | ||
PKG_CONFIG_PATH: "/usr/lib/x86_64-linux-gnu/pkgconfig" | ||
run: | | ||
cargo build --release --target ${{ matrix.target }} | ||
cp target/${{ matrix.target }}/release/main ${{ matrix.artifact_name }} | ||
- name: Generate SHA256 | ||
run: | | ||
${{ matrix.sha_cmd }} ${{ matrix.artifact_name }} > ${{ matrix.artifact_name }}.sha256 | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ matrix.artifact_name }} | ||
path: | | ||
${{ matrix.artifact_name }} | ||
${{ matrix.artifact_name }}.sha256 | ||
create-release: | ||
needs: build-release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
**/rustygate-* | ||
generate_release_notes: true |