diff --git a/.github/workflows/rust.yaml b/.github/workflows/main.yaml similarity index 59% rename from .github/workflows/rust.yaml rename to .github/workflows/main.yaml index 02ca37e78a..dcdf18d7c3 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/main.yaml @@ -10,6 +10,13 @@ jobs: - macos-latest - ubuntu-latest - windows-latest + 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 runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v1 @@ -17,6 +24,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: stable + target: ${{ matrix.target }} profile: minimal components: clippy, rustfmt override: true @@ -44,3 +52,17 @@ jobs: cargo run -- --completions $shell > $script done git diff --no-ext-diff --quiet --exit-code + - name: Package + id: package + if: startsWith(github.ref, 'refs/tags/v') + run: ./bin/package ${{github.ref}} ${{matrix.os}} ${{ matrix.target }} + shell: bash + - name: Publish + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/v') + with: + draft: false + files: ${{ steps.package.outputs.archive }} + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/bin/package b/bin/package new file mode 100755 index 0000000000..2b436309d8 --- /dev/null +++ b/bin/package @@ -0,0 +1,54 @@ +#!/usr/bin/env bash + +set -euxo pipefail + +version=${1#"refs/tags/"} +os=$2 +target=$3 +src=`pwd` +dist=$src/dist +bin=just + +echo "Packaging $bin $version for $target..." + +test -f Cargo.lock || cargo generate-lockfile + +echo "Building $bin..." + +case $os in + ubuntu-latest | macos-latest) + cargo rustc --bin $bin --target $target --release -- -C lto + executable=target/$target/release/$bin + ;; + windows-latest) + cargo rustc --bin $bin --target $target --release -- -C lto -C target-feature="+crt-static" + executable=target/$target/release/$bin.exe + ;; +esac + +echo "Copying release files..." +mkdir dist +cp -r \ + $executable \ + Cargo.lock \ + Cargo.toml \ + GRAMMAR.md \ + LICENSE \ + README.adoc \ + man \ + $dist + +cd $dist +echo "Creating release archive..." +case $os in + ubuntu-latest | macos-latest) + archive=$dist/$bin-$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" + ;; +esac diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 deleted file mode 100644 index 375bc050be..0000000000 --- a/ci/before_deploy.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -# This script takes care of packaging the build artifacts that will go in the -# release zipfile - -$SRC_DIR = $PWD.Path -$STAGE = [System.Guid]::NewGuid().ToString() - -Set-Location $ENV:Temp -New-Item -Type Directory -Name $STAGE -Set-Location $STAGE - -$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip" - -# DONE Update this to package the right artifacts -Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\just.exe" '.\' -Copy-Item "$SRC_DIR\GRAMMAR.md" '.\' -Copy-Item "$SRC_DIR\LICENSE" '.\' -Copy-Item "$SRC_DIR\README.adoc" '.\' - -7z a "$ZIP" * - -Push-AppveyorArtifact "$ZIP" - -Remove-Item *.* -Force -Set-Location .. -Remove-Item $STAGE -Set-Location $SRC_DIR diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh deleted file mode 100644 index 9ada8d2113..0000000000 --- a/ci/before_deploy.sh +++ /dev/null @@ -1,36 +0,0 @@ -# This script takes care of building your crate and packaging it for release - -set -ex - -main() { - local src=$(pwd) \ - stage= - - case $TRAVIS_OS_NAME in - linux) - stage=$(mktemp -d) - ;; - osx) - stage=$(mktemp -d -t tmp) - ;; - esac - - test -f Cargo.lock || cargo generate-lockfile - - # DONE Update this to build the artifacts that matter to you - cross rustc --bin just --target $TARGET --release -- -C lto - - # DONE Update this to package the right artifacts - cp target/$TARGET/release/just $stage/ - cp GRAMMAR.md $stage/ - cp LICENSE $stage/ - cp README.adoc $stage/ - - cd $stage - tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * - cd $src - - rm -rf $stage -} - -main diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100644 index 748ad9a9e8..0000000000 --- a/ci/install.sh +++ /dev/null @@ -1,27 +0,0 @@ -set -ex - -main() { - local target= - if [ $TRAVIS_OS_NAME = linux ]; then - target=x86_64-unknown-linux-musl - sort=sort - else - target=x86_64-apple-darwin - sort=gsort # for `sort --sort-version`, from brew's coreutils. - fi - - # This fetches latest stable release - local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ - | cut -d/ -f3 \ - | grep -E '^v[0.1.0-9.]+$' \ - | $sort --version-sort \ - | tail -n1) - curl -LSfs https://japaric.github.io/trust/install.sh | \ - sh -s -- \ - --force \ - --git japaric/cross \ - --tag $tag \ - --target $target -} - -main diff --git a/ci/script.sh b/ci/script.sh deleted file mode 100644 index fabbb59340..0000000000 --- a/ci/script.sh +++ /dev/null @@ -1,24 +0,0 @@ -# This script takes care of testing your crate - -set -ex - -# DONE This is the "test phase", tweak it as you see fit -main() { - cross build --target $TARGET - cross build --target $TARGET --release - - if [ ! -z $DISABLE_TESTS ]; then - return - fi - - cross test --target $TARGET - cross test --target $TARGET --release - - cross run --target $TARGET - cross run --target $TARGET --release -} - -# we don't run the "test phase" when doing deploys -if [ -z $TRAVIS_TAG ]; then - main -fi