Build and upload release artifacts from GitHub Actions (#581)
This commit is contained in:
parent
11bd8d448f
commit
4d175ada13
@ -10,6 +10,13 @@ jobs:
|
|||||||
- macos-latest
|
- macos-latest
|
||||||
- ubuntu-latest
|
- ubuntu-latest
|
||||||
- windows-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}}
|
runs-on: ${{matrix.os}}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
@ -17,6 +24,7 @@ jobs:
|
|||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
|
target: ${{ matrix.target }}
|
||||||
profile: minimal
|
profile: minimal
|
||||||
components: clippy, rustfmt
|
components: clippy, rustfmt
|
||||||
override: true
|
override: true
|
||||||
@ -44,3 +52,17 @@ jobs:
|
|||||||
cargo run -- --completions $shell > $script
|
cargo run -- --completions $shell > $script
|
||||||
done
|
done
|
||||||
git diff --no-ext-diff --quiet --exit-code
|
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
bin/package
Executable file
54
bin/package
Executable file
@ -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
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
24
ci/script.sh
24
ci/script.sh
@ -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
|
|
Loading…
Reference in New Issue
Block a user