diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a0ee30..82a2475 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,12 +20,11 @@ defaults: shell: bash jobs: - build: + all: name: - Build + All strategy: - fail-fast: false matrix: target: - aarch64-unknown-linux-gnu @@ -38,15 +37,19 @@ jobs: - target: x86_64-unknown-linux-musl os: ubuntu-latest native: true + - target: x86_64-apple-darwin os: macos-latest native: true + - target: arm64-apple-darwin os: macos-latest native: true + - target: x86_64-pc-windows-msvc os: windows-latest native: true + - target: aarch64-unknown-linux-gnu os: ubuntu-latest native: true @@ -54,26 +57,65 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Download source - uses: actions/checkout@v2 - - name: Install Crystal - uses: crystal-lang/install-crystal@v1 - - name: Install Just - uses: extractions/setup-just@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Build Justprep - run: just static=true crystal/build - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: crystal/bin/justprep - asset_name: ${{ matrix.asset-name }} - tag: ${{ github.ref }} - printInputs: - runs-on: ubuntu-latest - steps: - - run: | - echo "Log level: ${{ github.event.inputs.logLevel }}" - echo "Tags: ${{ github.event.inputs.tags }}" + # An issue with BSD Tar causes sporadic failures on macOS. + # c.f https://github.com/actions/cache/issues/403 + - name: Install GNU Tar + if: matrix.os == 'macos-latest' + run: | + brew install gnu-tar + echo /usr/local/opt/gnu-tar/libexec/gnubin > $GITHUB_PATH + + - name: Update Ubuntu Packages + if: matrix.os == 'ubuntu-latest' + run: | + sudo apt-get update + + - name: Download source + uses: actions/checkout@v2 + + - name: Install Crystal + uses: crystal-lang/install-crystal@v1 + + - name: Install Just + uses: extractions/setup-just@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Toolchain Versions Used + run: | + just --version + crystal --version + + - name: Build Justprep + run: just static=true crystal/build + + - name: Package + id: package + if: startsWith(github.ref, 'refs/tags/') + run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{ matrix.target }} + shell: bash + + - name: Publish + uses: softprops/action-gh-release@v0.1.5 + if: startsWith(github.ref, 'refs/tags/') + with: + draft: false + files: ${{ steps.package.outputs.archive }} + prerelease: ${{ steps.is_prerelease.outputs.value }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # - name: Upload binaries to release + # uses: svenstaro/upload-release-action@v2 + # with: + # repo_token: ${{ secrets.GITHUB_TOKEN }} + # file: crystal/bin/justprep + # asset_name: ${{ matrix.asset-name }} + # tag: ${{ github.ref }} + + # printInputs: + # runs-on: ubuntu-latest + # steps: + # - run: | + # echo "Log level: ${{ github.event.inputs.logLevel }}" + # echo "Tags: ${{ github.event.inputs.tags }}" diff --git a/bin/package b/bin/package new file mode 100755 index 0000000..4a270a9 --- /dev/null +++ b/bin/package @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# +# Adapted from https://github.com/casey/just/blob/master/bin/package +# Intended for use in github actions +# + +set -euxo pipefail + +REF=$1 +OS=$2 +TARGET=$3 +VERSION=${REF#"refs/tags/"} +DIST=`pwd`/dist +EXECUTABLE=crystal/bin/justprep + + +echo "Packaging justprep $VERSION for $TARGET..." + +echo "Building justprep ..." + +just crystal/build + + +if [[ $OS == windows-latest ]]; then + EXECUTABLE=$EXECUTABLE.exe +fi + +echo "Copying release files..." +mkdir dist +cp \ + $EXECUTABLE \ + LICENSE \ + CHANGELOG.md \ + README.md \ + $DIST + +cd $DIST +echo "Creating release archive..." + +case "$OS" in + "windows-latest") + ARCHIVE=$DIST/justprep-$VERSION-$TARGET.zip + 7z a $ARCHIVE * + echo "::set-output name=archive::`pwd -W`/just-$VERSION-$TARGET.zip" + ;; + *) + ARCHIVE=$DIST/justprep-$VERSION-$TARGET.tar.gz + tar czf $ARCHIVE * + echo "::set-output name=archive::$ARCHIVE" + ;; +esac