Skip to content

REL: Release v0.7.4 (#173) #53

REL: Release v0.7.4 (#173)

REL: Release v0.7.4 (#173) #53

Workflow file for this run

on:
push:
tags:
- "v*.*.*"
name: CD
jobs:
build_and_test_linux:
name: Build and Test (Linux)
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4.1.1
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- name: 'Build and test'
run: cargo nextest run --workspace --all-features
build_and_test_macos:
name: Build and Test (MacOS)
runs-on: macos-latest
timeout-minutes: 10
steps:
- name: Checkout sources
uses: actions/checkout@v4.1.1
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- name: 'Build and test'
run: cargo nextest run --workspace --all-features
build_and_release:
name: Build and Release
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os_name: Linux_x86_64
- target: i686-unknown-linux-gnu
os_name: Linux_32-bit
- target: i686-unknown-freebsd
os_name: freebsd_32-bit
- target: x86_64-unknown-freebsd
os_name: freebsd_x86_64
- target: aarch64-unknown-linux-gnu
os_name: Linux_arm64
# - target: x86_64-apple-darwin
# os_name: Darwin_x86_64
# - target: aarch64-apple-darwin
# os_name: Darwin_arm64
# - target: aarch64-unknown-freebsd
# os_name: freebsd_arm64
# - target: armv6-unknown-freebsd
# os_name: freebsd_armv6
# - target: armv6-unknown-linux-gnueabihf
# os_name: Linux_armv6
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Install cross
run: cargo install cross
- name: Build
run: cross build --target ${{ matrix.target }} --release
- name: Rename binary
run: |
# Convert to lower case and replace '-' with '_'
target=${{ matrix.target }}
target_modified=$(echo "$target" | tr '[:upper:]' '[:lower:]' | tr '-' '_')
# Get the current tag
current_tag=$(git describe --tags)
prefix=_"${target_modified}"_"${current_tag}".bin
# Rename the file
cd ./target/${{ matrix.target }}/release/
mv ohcrab ohcrab"$prefix"
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ./target/${{ matrix.target }}/release/ohcrab*.bin
build_and_release_macos:
name: Build and Release
runs-on: macos-13
permissions:
contents: write
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os_name: Darwin_x86_64
- target: aarch64-apple-darwin
os_name: Darwin_arm64
steps:
- name: Checkout code
uses: actions/checkout@v4.1.1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
override: true
# - name: Add target
# run: rustup target add ${{ matrix.target }}
- name: Install the linker
run: brew install FiloSottile/musl-cross/musl-cross
# - name: Install cross
# run: cargo install cross
- name: Build
run: cargo build --target ${{ matrix.target }} --release
- name: List files
run: ls ./target/${{ matrix.target }}/release/
- name: Rename binary
run: |
# Convert to lower case and replace '-' with '_'
target=${{ matrix.target }}
target_modified=$(echo "$target" | tr '[:upper:]' '[:lower:]' | tr '-' '_')
# Get the current tag
current_tag=$(git describe --tags)
prefix=_"${target_modified}"_"${current_tag}".bin
# Rename the file
cd ./target/${{ matrix.target }}/release/
mv ohcrab ohcrab"$prefix"
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: ./target/${{ matrix.target }}/release/ohcrab*.bin
crates_io_publish:
name: Publish (crates.io)
needs:
# - audit
- build_and_test_linux
- build_and_test_macos
- build_and_release
- build_and_release_macos
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v4.1.1
- uses: dtolnay/rust-toolchain@stable
- name: cargo-release Cache
id: cargo_release_cache
uses: actions/cache@v3
with:
path: ~/.cargo/bin/cargo-release
key: ${{ runner.os }}-cargo-release
- run: cargo install cargo-release
if: steps.cargo_release_cache.outputs.cache-hit != 'true'
- name: cargo login
run: cargo login ${{ secrets.CRATES_IO_API_TOKEN }}
# allow-branch HEAD is because GitHub actions switches
# to the tag while building, which is a detached head
# Publishing is currently messy, because:
#
# * `peace_rt_model_core` exports `NativeError` or `WebError` depending on the target.
# * `peace_rt_model_web` fails to build when publishing the workspace for a native target.
# * `peace_rt_model_web` still needs its dependencies to be published before it can be
# published.
# * `peace_rt_model_hack` needs `peace_rt_model_web` to be published before it can be
# published.
#
# We *could* pass through `--no-verify` so `cargo` doesn't build the crate before publishing,
# which is reasonable, since this job only runs after the Linux, Windows, and WASM builds
# have passed.
- name: "cargo release publish"
run: |-
cargo release \
publish \
--workspace \
--all-features \
--allow-branch HEAD \
--no-confirm \
--no-verify \
--execute