Skip to content

Commit

Permalink
Build releases for more targets
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Sep 3, 2024
1 parent e2a4815 commit 2a66703
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 44 deletions.
55 changes: 41 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,51 @@ defaults:
run:
shell: bash

env:
RUSTFLAGS: --deny warnings

jobs:
all:
name: All

strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
target:
- aarch64-apple-darwin
- aarch64-unknown-linux-musl
- arm-unknown-linux-musleabihf
- armv7-unknown-linux-musleabihf
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- aarch64-pc-windows-msvc
- x86_64-unknown-linux-musl
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
- target: aarch64-apple-darwin
os: macos-latest
target_rustflags: ''
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
target_rustflags: '--codegen linker=aarch64-linux-gnu-gcc'
- target: arm-unknown-linux-musleabihf
os: ubuntu-latest
target_rustflags: '--codegen linker=arm-linux-gnueabihf-gcc'
- target: armv7-unknown-linux-musleabihf
os: ubuntu-latest
target_rustflags: '--codegen linker=arm-linux-gnueabihf-gcc'
- target: x86_64-apple-darwin
os: macos-latest
target_rustflags: ''
- target: x86_64-pc-windows-msvc
os: windows-latest
- target: aarch64-pc-windows-msvc
os: windows-latest
target_rustflags: ''
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
target_rustflags: ''

runs-on: ${{matrix.os}}

env:
RUSTFLAGS: --deny warnings

steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -118,7 +140,12 @@ jobs:
- name: Package
id: package
if: startsWith(github.ref, 'refs/tags/')
run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{matrix.target}}
env:
TARGET: ${{ matrix.target }}
REF: ${{ github.ref }}
OS: ${{ matrix.os }}
TARGET_RUSTFLAGS: ${{ matrix.target_rustflags }}
run: ./bin/package

- name: Publish Release Archive
uses: softprops/action-gh-release@v1
Expand Down
56 changes: 26 additions & 30 deletions bin/package
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

set -euxo pipefail

version=${1#"refs/tags/"}
os=$2
target=$3
src=`pwd`
dist=$src/target/dist
bin=imdl
VERSION=${REF#"refs/tags/"}
DIST=`pwd`/target/dist

echo "Packaging $bin $version for $target..."
echo "Packaging imdl $VERSION for $TARGET..."

test -f Cargo.lock || cargo generate-lockfile

echo "Building $bin..."
echo "Building imdl..."

case $os in
case $OS in
ubuntu-latest)
sudo apt install help2man musl-tools
;;
Expand All @@ -26,53 +22,53 @@ case $os in
;;
esac

RUSTFLAGS='--deny warnings --codegen target-feature=+crt-static' \
cargo build --bin $bin --target $target --release
executable=target/$target/release/$bin
RUSTFLAGS="--deny warnings --codegen target-feature=+crt-static $TARGET_RUSTFLAGS" \
cargo build --bin imdl --target $TARGET --release
EXECUTABLE=target/$TARGET/release/imdl

if [[ $os == windows-2016 ]]; then
executable=$executable.exe
if [[ $OS == windows-2016 ]]; then
EXECUTABLE=$EXECUTABLE.exe
fi

echo "Building completions..."
cargo run --package gen -- --bin $executable completion-scripts
cargo run --package gen -- --bin $EXECUTABLE completion-scripts

echo "Generating readme..."
cargo run --package gen -- --bin $executable readme
cargo run --package gen -- --bin $EXECUTABLE readme

echo "Copying static files..."
mkdir $dist
mkdir $DIST
cp -r \
$executable \
$EXECUTABLE \
CONTRIBUTING \
Cargo.lock \
Cargo.toml \
LICENSE \
$dist
$DIST

echo "Copying generated files..."
cp -r \
target/gen/README.md \
target/gen/completions \
$dist
$DIST

if [[ $os != windows-latest ]]; then
if [[ $OS != windows-latest ]]; then
echo "Building man pages..."
cargo run --package gen -- --bin $executable man
cp -r target/gen/man $dist/man
cargo run --package gen -- --bin $EXECUTABLE man
cp -r target/gen/man $DIST/man
fi

cd $dist
cd $DIST
echo "Creating release archive..."
case $os in
case $OS in
ubuntu-latest | macos-latest)
archive=$dist/$bin-$version-$target.tar.gz
tar czf $archive *
ARCHIVE=$DIST/imdl-$VERSION-$TARGET.tar.gz
tar czf $ARCHIVE *
echo "::set-output name=archive::$archive"
;;
windows-latest)
archive=$dist/$bin-$version-$target.zip
7z a $archive *
echo "::set-output name=archive::`pwd -W`/$bin-$version-$target.zip"
ARCHIVE=$DIST/imdl-$VERSION-$TARGET.zip
7z a $ARCHIVE *
echo "::set-output name=archive::`pwd -W`/imdl-$VERSION-$TARGET.zip"
;;
esac

0 comments on commit 2a66703

Please sign in to comment.