-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from robyoung/add-ci-and-release-workflows
Add CI and Release workflows
- Loading branch information
Showing
3 changed files
with
138 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,48 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
push: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
name: Test | ||
|
||
strategy: | ||
matrix: | ||
rust: | ||
- stable | ||
- nightly | ||
os: | ||
- ubuntu-latest | ||
- macos-latest | ||
- windows-2019 | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
override: true | ||
|
||
- run: cargo test | ||
|
||
static: | ||
name: Static analysis | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
- run: cargo fmt --all -- --check | ||
- run: cargo install cargo-audit | ||
- run: cargo clippy | ||
- run: cargo audit |
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,89 @@ | ||
# A lot of this is lifted from https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/release.yml | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
include: | ||
- build: linux | ||
os: ubuntu-latest | ||
target: x86_64-unknown-linux-musl | ||
|
||
- build: linux-arm | ||
os: ubuntu-latest | ||
target: arm-unknown-linux-gnueabihf | ||
|
||
- build: macos | ||
os: macos-latest | ||
target: x86_64-apple-darwin | ||
|
||
- build: win-msvc | ||
os: windows-2019 | ||
target: x86_64-pc-windows-msvc | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install packages (Ubuntu) | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y --no-install-recommends musl-tools | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
profile: minimal | ||
override: true | ||
target: ${{ matrix.target }} | ||
|
||
- name: Install Cross | ||
run: | | ||
cargo install cross | ||
- name: Build release binary | ||
run: | | ||
cross build --verbose --release --target ${{ matrix.target }} | ||
- name: Strip release binary (linux and macos) | ||
if: matrix.build == 'linux' || matrix.build == 'macos' | ||
run: strip "target/${{ matrix.target }}/release/y2j" | ||
|
||
- name: Strip release binary (arm) | ||
if: matrix.build == 'linux-arm' | ||
run: | | ||
docker run --rm \ | ||
-v "$PWD/target:/target:Z" \ | ||
rustembedded/cross:arm-unknown-linux-gnueabihf \ | ||
arm-linux-gnueabihf-strip \ | ||
/target/arm-unknown-linux-gnueabihf/release/rg | ||
- name: Release vars | ||
id: vars | ||
run: | | ||
version=${GITHUB_REF#refs/tags/} | ||
echo ::set-output name=VERSION::${version} | ||
echo ::set-output name=FILE_NAME::y2j-${version}-${{ matrix.target }} | ||
- name: Rename release binary | ||
run: | | ||
cp "target/${{ matrix.target }}/release/y2j" ${{ steps.vars.FILE_NAME }} | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
path: ${{ steps.vars.FILE_NAME }} | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/download-artifact@v2 | ||
- run: ls -l |
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
!/.github/ |