Skip to content

Commit

Permalink
Build related updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Sep 26, 2022
1 parent 4b68d64 commit 893dcf4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 70 deletions.
135 changes: 65 additions & 70 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+"
jobs:
create-release:
name: create-release
Expand All @@ -28,7 +28,7 @@ jobs:

build-release:
name: build-release
needs: ['create-release']
needs: ["create-release"]
runs-on: ${{ matrix.os }}
env:
CARGO: cargo
Expand All @@ -37,80 +37,75 @@ jobs:
RUST_BACKTRACE: 1
strategy:
matrix:
build: [linux, linux-arm, macos]
build: [linux, linux-arm, linux-arm64, macos, macos-m1]
include:
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
- build: linux-arm
os: ubuntu-latest
rust: stable
target: arm-unknown-linux-gnueabihf
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
- build: linux-arm
os: ubuntu-latest
rust: stable
target: arm-unknown-linux-gnueabihf
- build: linux-arm64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: macos-m1
os: macos-latest
rust: stable
target: aarch64-apple-darwin

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}

- name: Use Cross
shell: bash
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET_FLAGS }}"
echo "target dir is: ${{ env.TARGET_DIR }}"
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}

- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
- name: Use Cross
shell: bash
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Strip release binary (linux and macos)
if: matrix.build == 'linux' || matrix.build == 'macos'
run: strip "target/${{ matrix.target }}/release/findlargedir"
- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET_FLAGS }}"
echo "target dir is: ${{ env.TARGET_DIR }}"
- name: Strip release binary (arm)
if: matrix.build == 'linux-arm'
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
rustembedded/cross:arm-unknown-linux-gnueabihf \
arm-linux-gnueabihf-strip \
/target/arm-unknown-linux-gnueabihf/release/findlargedir
- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}

- name: Build archive
shell: bash
run: |
outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")"
staging="findlargedir-${{ needs.create-release.outputs.fl_version }}-${{ matrix.target }}"
mkdir -p "$staging"
cp {README.md,LICENSE} "$staging"
cp "target/${{ matrix.target }}/release/findlargedir" "$staging"
tar -cJf "$staging.tar.xz" "$staging"
echo "ASSET=$staging.tar.xz" >> $GITHUB_ENV
- name: Build archive
shell: bash
run: |
outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")"
staging="findlargedir-${{ needs.create-release.outputs.fl_version }}-${{ matrix.target }}"
mkdir -p "$staging"
cp {README.md,LICENSE} "$staging"
cp "target/${{ matrix.target }}/release/findlargedir" "$staging"
tar -cJf "$staging.tar.xz" "$staging"
echo "ASSET=$staging.tar.xz" >> $GITHUB_ENV
- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ fs-err = "2.8.1"

[profile.release]
lto = true
strip = true

0 comments on commit 893dcf4

Please sign in to comment.