Skip to content

Commit

Permalink
Build and upload release artifacts from GitHub Actions (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 28, 2020
1 parent 11bd8d4 commit 4d175ad
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 113 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/rust.yaml → .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ 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
- name: Install
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
profile: minimal
components: clippy, rustfmt
override: true
Expand Down Expand Up @@ -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 }}
54 changes: 54 additions & 0 deletions bin/package
Original file line number Diff line number Diff line change
@@ -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
26 changes: 0 additions & 26 deletions ci/before_deploy.ps1

This file was deleted.

36 changes: 0 additions & 36 deletions ci/before_deploy.sh

This file was deleted.

27 changes: 0 additions & 27 deletions ci/install.sh

This file was deleted.

24 changes: 0 additions & 24 deletions ci/script.sh

This file was deleted.

0 comments on commit 4d175ad

Please sign in to comment.