-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github action workflows for tests and releases
- Loading branch information
Showing
3 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-and-clippy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Run tests | ||
run: cargo test --verbose | ||
|
||
- name: Run clippy | ||
run: cargo clippy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-and-clippy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Run tests | ||
run: cargo test --verbose | ||
|
||
- name: Run clippy | ||
run: cargo clippy | ||
|
||
# Cross-compilation builds for other targets, using `cross`, from linux | ||
linux-cross-build: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- test-and-clippy | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- aarch64-unknown-linux-musl | ||
- arm-unknown-linux-musleabi | ||
- i686-unknown-linux-musl | ||
- x86_64-pc-windows-gnu | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install cross | ||
run: cargo install cross | ||
|
||
- name: Build for ${{ matrix.target }} | ||
run: scripts/cross-build.sh ${{ matrix.target }} | ||
|
||
- name: Upload ${{ matrix.target }} artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: release-${{ matrix.target }} | ||
path: release-dist/* | ||
|
||
- name: Upload github release executable | ||
run: | | ||
export PATH=$PATH:$(go env GOPATH)/bin | ||
go get github.com/tcnksm/ghr | ||
version=$(git describe --tags | tr -d '\n') | ||
ghr "${version}" release-dist/bouffalo-cli-*.gz | ||
macos-build: | ||
runs-on: macos-latest | ||
needs: | ||
- test-and-clippy | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Build release | ||
run: cargo build --verbose --release | ||
|
||
- name: Prepare artifacts | ||
run: | | ||
mkdir -p target/dist | ||
version=$(git describe --tags | tr -d '\n') | ||
bin="target/dist/bouffalo-cli-${version}-x86_64-apple-darwin" | ||
cp target/release/bouffalo-cli "${bin}" | ||
gzip "${bin}" | ||
export PATH=$PATH:$(go env GOPATH)/bin | ||
go get github.com/tcnksm/ghr | ||
ghr "${version}" target/dist/*.gz | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: release-x86_64-apple-darwin | ||
path: target/dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This scripts attempts to build the project using `cross` for a given target | ||
|
||
if [ $# -ne 1 ]; then | ||
echo "Usage ${0} <target>" | ||
exit 1 | ||
fi | ||
|
||
target=${1} | ||
temp_dir="release-dist" | ||
version=$(git describe --tags | tr -d '\n') | ||
|
||
mkdir -p "${temp_dir}" | ||
|
||
set -e -x | ||
|
||
echo "Building for target ${target}" | ||
|
||
cross build --verbose --release --target="${target}" | ||
|
||
# Copy the binary to the temporary directory | ||
if [[ $target =~ "-pc-windows-gnu" ]]; then | ||
ext=.exe | ||
else | ||
ext= | ||
fi | ||
|
||
rls_path="target/${target}/release" | ||
# | ||
if [ -e "${rls_path}/bouffalo-cli${ext}" ]; then | ||
rls_name="bouffalo-cli-${version}-${target}" | ||
cp "${rls_path}/bouffalo-cli${ext}" "${temp_dir}/${rls_name}${ext}" | ||
gzip "${temp_dir}/${rls_name}${ext}" | ||
fi |