Release Binaries #17
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 ${{ matrix.artifact_name }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
artifact_name: rustygate-linux-amd64 | |
sha_cmd: sha256sum | |
container: alpine:3.19 | |
- os: ubuntu-latest | |
target: aarch64-unknown-linux-musl | |
artifact_name: rustygate-linux-arm64 | |
sha_cmd: sha256sum | |
container: alpine:3.19 | |
- 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" | |
# Only use container for Linux builds | |
container: ${{ matrix.container != '' && format('{0}', matrix.container) || null }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install basic dependencies (Alpine) | |
if: matrix.container != '' | |
run: | | |
apk add --no-cache \ | |
build-base \ | |
openssl-dev \ | |
openssl-libs-static \ | |
pkgconfig \ | |
gcc \ | |
musl-dev \ | |
bash \ | |
curl | |
- name: Install cross-compilation tools (ARM64) | |
if: matrix.target == 'aarch64-unknown-linux-musl' | |
run: | | |
apk add --no-cache \ | |
aarch64-linux-musl-gcc \ | |
linux-headers | |
- name: Setup cross-compilation environment (ARM64) | |
if: matrix.target == 'aarch64-unknown-linux-musl' | |
run: | | |
# Create pkg-config wrapper for cross-compilation | |
echo '#!/bin/sh' > /usr/local/bin/aarch64-linux-musl-pkg-config | |
echo 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/share/pkgconfig pkg-config "$@"' >> /usr/local/bin/aarch64-linux-musl-pkg-config | |
chmod +x /usr/local/bin/aarch64-linux-musl-pkg-config | |
# Set environment variables for cross-compilation | |
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV | |
echo "PKG_CONFIG=aarch64-linux-musl-pkg-config" >> $GITHUB_ENV | |
echo "OPENSSL_DIR=/usr" >> $GITHUB_ENV | |
echo "OPENSSL_STATIC=1" >> $GITHUB_ENV | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.target }} | |
- name: Build binary | |
env: | |
OPENSSL_STATIC: 1 | |
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 | |
container: | |
image: alpine:3.19 | |
options: --user root | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
apk add --no-cache git curl | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
**/rustygate-* | |
generate_release_notes: true |