Skip to content

Build

Build #42

Workflow file for this run

name: Build
on:
release:
types: [published]
workflow_dispatch:
jobs:
build-windows:
runs-on: windows-latest
strategy:
matrix:
target: [x86_64-pc-windows-msvc]
env:
CRATE_NAME: "clue"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache build
uses: Swatinem/rust-cache@v2
- name: Build ${{ matrix.target }}
run: |
cargo build --target=${{ matrix.target }} --release -vv
cd target\${{ matrix.target }}\release && tar -cavf "$env:CRATE_NAME-${{ matrix.target }}.zip" "$env:CRATE_NAME.exe" && cd ../../..
- name: Upload clue-${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.CRATE_NAME }}-${{ matrix.target }}.zip
path: target\${{ matrix.target }}\release\${{ env.CRATE_NAME }}-${{ matrix.target }}.zip
- name: Publish in release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: |
target/${{ matrix.target }}/release/${{ env.CRATE_NAME }}-${{ matrix.target }}.zip
token: ${{ secrets.GITHUB_TOKEN }}
build-macos:
runs-on: macos-latest
strategy:
matrix:
target: [x86_64-apple-darwin, aarch64-apple-darwin]
env:
CRATE_NAME: "clue"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache build
uses: Swatinem/rust-cache@v2
- name: Setup
run: rustup target add ${{ matrix.target }}
- name: Build ${{ matrix.target }}
env:
TARGET_LDFLAGS: "--target=${{ matrix.target }}"
TARGET_CFLAGS: "--target=${{ matrix.target }}"
run: |
cargo build --release --target=${{ matrix.target }} -vv
( cd target/${{ matrix.target }}/release/ && tar -cavf "$CRATE_NAME-${{ matrix.target }}.tar.gz" "$CRATE_NAME" )
- name: Upload clue-${{ matrix.target }}.tar.gz
uses: actions/upload-artifact@v4
with:
name: ${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
path: target/${{ matrix.target }}/release/${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
- name: Publish in release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: |
target/${{ matrix.target }}/release/${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
build-gnu-linux:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
host_cc: ""
target_cc: ""
- target: aarch64-unknown-linux-gnu
host_cc: ""
target_cc: aarch64-linux-gnu
- target: armv7-unknown-linux-gnueabi
host_cc: i686-linux-gnu
target_cc: arm-linux-gnueabi
- target: armv7-unknown-linux-gnueabihf
host_cc: i686-linux-gnu
target_cc: arm-linux-gnueabihf
env:
CRATE_NAME: "clue"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache build
uses: Swatinem/rust-cache@v2
- name: Setup
run: |
rustup target add ${{ matrix.target }}
cargo install cargo-deb cargo-make-rpm
write_var(){
echo "$1=$(eval echo \$$1)" >> $GITHUB_ENV
}
sudo apt update
if ! [[ -z "${{ matrix.host_cc }}" ]]; then
export HOST_CC="${{ matrix.host_cc }}-gcc"
write_var HOST_CC
sudo apt install -y -qq gcc-${{ matrix.host_cc }}
fi
if ! [[ -z "${{ matrix.target_cc }}" ]]; then
export TARGET_CC="${{ matrix.target_cc }}-gcc"
write_var TARGET_CC
sudo apt install -y -qq gcc-${{ matrix.target_cc }}
mkdir -p .cargo
echo '[target.${{ matrix.target }}]'>>.cargo/config
echo "linker = \"$TARGET_CC\"">>.cargo/config
fi
- name: Build ${{ matrix.target }}
run: |
cargo build --target=${{ matrix.target }} --release -vv
( cd target/${{ matrix.target }}/release/ && tar -cavf "$CRATE_NAME-${{ matrix.target }}.tar.gz" "$CRATE_NAME" )
- name: Build deb
run: |
cd cli && cargo deb -p clue --target=${{ matrix.target }} && cd ..
echo "DEB_FILENAME=$(basename $(echo target/${{ matrix.target }}/debian/*.deb))" >> $GITHUB_ENV
- name: Build rpm
run: |
cargo-make-rpm -p clue --target=${{ matrix.target }}
echo "RPM_FILENAME=$(basename $(echo target/${{ matrix.target }}/rpm/*.rpm))" >> $GITHUB_ENV
- name: Upload ${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
uses: actions/upload-artifact@v4
with:
name: ${{ env.CRATE_NAME }}-${{ matrix.target }}.tar.gz
path: target/${{ matrix.target }}/release/*.tar.gz
- name: Upload ${{ env.DEB_FILENAME }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.DEB_FILENAME }}
path: target/${{ matrix.target }}/debian/*.deb
- name: Upload ${{ env.RPM_FILENAME }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.RPM_FILENAME }}
path: target/${{ matrix.target }}/rpm/*.rpm
- name: Publish in release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: |
target/${{ matrix.target }}/release/*.tar.gz
target/${{ matrix.target }}/debian/*.deb
target/${{ matrix.target }}/rpm/*.rpm
build-wasm:
runs-on: ubuntu-latest
env:
CRATE_NAME: "clue"
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Cache build
uses: Swatinem/rust-cache@v2
- name: Setup
run: |
rustup target add wasm32-unknown-unknown
cargo install wasm-pack
- name: Build wasm
run: |
cd wasm
wasm-pack build --target web --release
zip -r clue_wasm.zip pkg
- name: Upload clue_wasm.zip
uses: actions/upload-artifact@v4
with:
name: clue_wasm.zip
path: wasm/clue_wasm.zip
- name: Publish in release
uses: softprops/action-gh-release@v1
if: github.ref_type == 'tag'
with:
files: |
wasm/clue_wasm.zip