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 050069b
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 48 deletions.
63 changes: 45 additions & 18 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-pc-windows-msvc
- aarch64-unknown-linux-musl
- arm-unknown-linux-musleabihf
- armv7-unknown-linux-musleabihf
- x86_64-apple-darwin
- x86_64-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-pc-windows-msvc
os: windows-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: 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 @@ -76,7 +98,7 @@ jobs:
run: cargo clippy --all-targets --all-features

- name: Lint
if: matrix.os == 'macos-latest'
if: matrix.target == 'x86_64-apple-darwin'
run: |
brew install ripgrep
./bin/lint
Expand All @@ -85,7 +107,7 @@ jobs:
run: cargo fmt --all -- --check

- name: Check Generated
if: matrix.os == 'macos-latest'
if: matrix.target == 'x86_64-apple-darwin'
run: |
brew install help2man
cargo run --package gen -- --bin target/debug/imdl all
Expand All @@ -104,12 +126,12 @@ jobs:
mdbook build book --dest-dir ../www/book
- name: Record Git Revision
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest'
if: github.ref == 'refs/heads/master' && matrix.os == 'x86_64-unknown-linux-musl'
run: git rev-parse --verify HEAD > www/head.txt

- name: Deploy Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest'
if: github.ref == 'refs/heads/master' && matrix.os == 'x86_64-unknown-linux-musl'
with:
github_token: ${{secrets.GITHUB_TOKEN}}
publish_branch: gh-pages
Expand All @@ -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 050069b

Please sign in to comment.