Skip to content

Update release.yml

Update release.yml #55

Workflow file for this run

name: Build and Relaese
on:
push:
pull_request:
types: [opened, reopened, edited, synchronize]
workflow_dispatch:
inputs:
fail-fast:
description: 'Terminate all jobs if one fails'
required: true
default: true
type: boolean
run-cross:
description: 'Run cross-compile on Linux'
required: true
default: true
type: boolean
run-apple:
description: 'Run job on macOS'
required: true
default: true
type: boolean
publish-release:
description: 'Publish a release'
required: true
default: false
type: boolean
jobs:
cross-compile:
if: ${{ inputs.run-cross }} || github.event.issue.pull_request
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
fail-fast: ${{ inputs.fail-fast }}
matrix:
target:
- aarch64-linux-android
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
- armv7-unknown-linux-musleabihf
- i686-pc-windows-gnu
- i686-unknown-linux-gnu
# - mips64-unknown-linux-muslabi64
# - mips64el-unknown-linux-muslabi64
# - powerpc64-unknown-linux-gnu
# - powerpc64le-unknown-linux-gnu
# - riscv64gc-unknown-linux-gnu
- x86_64-pc-windows-gnu
- x86_64-unknown-freebsd
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
steps:
- uses: actions/checkout@v4
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
with:
key: "v2"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: build
run: cross build --release --target ${{ matrix.target }}
# - run: ls target/${{ matrix.target }}/release
- name: Rename artifact
run: >
cp
${{ format('target/{0}/release/solver-multi{1}', matrix.target, contains(matrix.target, 'windows') && '.exe' || '') }}
${{ format('solver-multi_{0}{1}', matrix.target, contains(matrix.target, 'windows') && '.exe' || '') }}
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
files: ${{ format('solver-multi_{0}{1}', matrix.target, contains(matrix.target, 'windows') && '.exe' || '') }}
if: ${{ !github.event.issue.pull_request }} && startsWith( github.ref, 'refs/tags/v' ) || contains(github.event.head_commit.message, 'test release') || ${{ inputs.publish-release }}
build-for-mac:
if: ${{ inputs.run-apple }}
runs-on: macos-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
with:
key: "v2"
- name: Install latest rust toolchain
run: |
rustup update stable
rustup target install x86_64-apple-darwin
rustup target install aarch64-apple-darwin
- name: Build for mac
run: cargo build --release --target x86_64-apple-darwin
- name: Rename artifact (x86_64)
run: >
cp
target/x86_64-apple-darwin/release/solver-multi
solver-multi_x86_64-apple-darwin
- name: Cross-compile Apple Silicon
run: cargo build --release --target aarch64-apple-darwin
- name: Rename artifact (aarch64)
run: >
cp
target/aarch64-apple-darwin/release/solver-multi
solver-multi_aarch64-apple-darwin
- name: List directory
run: ls target
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
with:
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
files: |
solver-multi_x86_64-apple-darwin
solver-multi_aarch64-apple-darwin
if: startsWith( github.ref, 'refs/tags/v' ) || contains(github.event.head_commit.message, 'test release') || ${{ inputs.publish-release }}