diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f093055..ab23e35 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/bin/package b/bin/package index 78e6b07..5791755 100755 --- a/bin/package +++ b/bin/package @@ -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 ;; @@ -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