Skip to content

Build and Release

Build and Release #31

Workflow file for this run

name: Cross Build and Release
on:
workflow_dispatch:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
permissions:
contents: write
jobs:
# build-windows:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
#
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# override: true
# toolchain: stable
# target: x86_64-pc-windows-gnu
#
# - name: Install cross
# run: cargo install cross --git https://github.com/cross-rs/cross
#
# - name: Build for Windows
# run: cross build --release --target x86_64-pc-windows-gnu
#
# - name: Create artifacts directory
# run: mkdir artifacts
#
# - name: Copy binary to artifacts
# run: cp target/x86_64-pc-windows-gnu/release/jobshell.exe artifacts/
#
# - name: Upload Windows binary
# uses: actions/upload-artifact@v3
# with:
# name: windows-artifacts
# path: artifacts/
#
# build-macos:
# runs-on: macos-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
#
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# override: true
# toolchain: stable
#
# - name: Add macOS targets
# run: |
# rustup target add x86_64-apple-darwin
# rustup target add aarch64-apple-darwin
#
# - name: Create artifacts directory
# run: mkdir artifacts
#
# - name: Build for macOS (x86_64)
# run: cargo build --release --target x86_64-apple-darwin
#
# - name: Copy x86_64 binary
# run: cp target/x86_64-apple-darwin/release/jobshell artifacts/jobshell-x86_64
#
# - name: Build for macOS (aarch64)
# run: cargo build --release --target aarch64-apple-darwin
#
# - name: Copy aarch64 binary
# run: cp target/aarch64-apple-darwin/release/jobshell artifacts/jobshell-aarch64
#
# - name: Upload macOS binaries
# uses: actions/upload-artifact@v3
# with:
# name: macos-artifacts
# path: artifacts/
#
# release:
# needs: [build-windows, build-macos]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
#
# - name: Create release directory
# run: mkdir release-binaries
#
# - name: Download all artifacts
# uses: actions/download-artifact@v3
# with:
# path: release-binaries
#
# - name: Create Release
# id: create_release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: ${{ github.ref_name }}
# release_name: Release ${{ github.ref_name }}
# draft: false
# prerelease: false
#
# - name: Upload Windows Binary
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: release-binaries/windows-artifacts/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
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: release-binaries/macos-artifacts/jobshell-x86_64
# asset_name: jobshell-macos-x86_64
# asset_content_type: application/octet-stream
#
# - name: Upload macOS aarch64 Binary
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: release-binaries/macos-artifacts/jobshell-aarch64
# asset_name: jobshell-macos-aarch64
# asset_content_type: application/octet-stream
publish-to-cargo:
# needs: [release]
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Install Rust
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
# Step 3: Validate the package
- name: Validate Cargo Package
run: cargo package --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# Step 4: Publish to Crates.io
- name: Publish to crates.io
run: cargo publish --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}