Skip to content

Cross Build and Release #17

Cross Build and Release

Cross Build and Release #17

Workflow file for this run

name: Cross Build and Release
on:
workflow_dispatch: # Enables manual triggering
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Matches tags like v1.0.0, v2.3.4, etc.
permissions:
contents: write
jobs:
build-windows:
runs-on: ubuntu-latest
steps:
# Checkout the code
- name: Checkout repository
uses: actions/checkout@v3
# Install Rust
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true # Set as the default Rust version
toolchain: stable
# Install `cross`
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
# Build for Windows
- name: Build for Windows (x86_64-pc-windows-gnu)
run: cross build --release --target x86_64-pc-windows-gnu
# Upload Windows binary as artifact
- name: Upload Windows binary
uses: actions/upload-artifact@v3
with:
name: windows-binary
path: target/x86_64-pc-windows-gnu/release/jobshell.exe
build-macos:
runs-on: macos-latest
steps:
# Checkout the code
- name: Checkout repository
uses: actions/checkout@v3
# Install Rust
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true # Set as the default Rust version
toolchain: stable
# Install required targets for macOS
- name: Install macOS targets
run: |
rustup target add x86_64-apple-darwin
rustup target add aarch64-apple-darwin
# Build for macOS (x86_64)
- name: Build for macOS (x86_64-apple-darwin)
run: cargo build --release --target x86_64-apple-darwin
# Upload macOS (x86_64) binary as artifact
- name: Upload macOS (x86_64) binary
uses: actions/upload-artifact@v3
with:
name: jobshell-macos-x86_64-binary
path: target/x86_64-apple-darwin/release/jobshell
# Build for macOS (aarch64)
- name: Build for macOS (aarch64-apple-darwin)
run: cargo build --release --target aarch64-apple-darwin
# Upload macOS (aarch64) binary as artifact
- name: Upload macOS (aarch64) binary
uses: actions/upload-artifact@v3
with:
name: jobshell-macos-aarch64-binary
path: target/aarch64-apple-darwin/release/jobshell
release:
runs-on: ubuntu-latest
needs:
- build-windows
- build-macos
steps:
# Checkout the code
- name: Checkout repository
uses: actions/checkout@v3
# Download Windows artifact
- name: Download Windows artifact
uses: actions/download-artifact@v3
with:
name: windows-binary
# Download macOS artifacts
- name: Download macOS (x86_64) artifact
uses: actions/download-artifact@v3
with:
name: jobshell-macos-x86_64-binary
- name: Download macOS (aarch64) artifact
uses: actions/download-artifact@v3
with:
name: jobshell-macos-aarch64-binary
# Create GitHub Release
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref_name }} # Use the latest pushed tag
release_name: "Release ${{ github.ref_name }}"
body: |
### Changes in this Release
- Windows and macOS binaries included.
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Upload Release Assets
- name: Upload Windows binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/x86_64-pc-windows-gnu/release/jobshell.exe
asset_name: jobshell-windows-x86_64.exe
asset_content_type: application/octet-stream
- name: Upload macOS (x86_64) binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/x86_64-apple-darwin/release/jobshell
asset_name: jobshell-macos-x86_64
asset_content_type: application/octet-stream
- name: Upload macOS (aarch64) binary
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: target/aarch64-apple-darwin/release/jobshell
asset_name: jobshell-macos-aarch64
asset_content_type: application/octet-stream