generated from EmbarkStudios/opensource-template
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace travis with GH actions (#16)
- Loading branch information
1 parent
f9de4ff
commit 48eef7c
Showing
7 changed files
with
221 additions
and
341 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,221 @@ | ||
on: [push, pull_request] | ||
name: CI | ||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
|
||
# make sure all code has been formatted with rustfmt | ||
- run: rustup component add rustfmt | ||
- name: check rustfmt | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: -- --check --color always | ||
|
||
# run clippy to verify we have no warnings | ||
- run: rustup component add clippy | ||
- name: cargo fetch | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fetch | ||
- name: cargo clippy | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: --lib --tests -- -D warnings | ||
|
||
test: | ||
name: Test | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macOS-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
- name: cargo fetch | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fetch | ||
- name: cargo test build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --tests --release | ||
- name: cargo test | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: test | ||
args: --release | ||
|
||
# Remove this check if you don't use cargo-deny in the repo | ||
deny-check: | ||
name: cargo-deny check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: download cargo-deny | ||
shell: bash | ||
env: | ||
DVS: 0.3.0-beta | ||
DREPO: EmbarkStudios/cargo-deny | ||
TARGET: x86_64-unknown-linux-musl | ||
run: | | ||
temp_archive=$(mktemp --suffix=.tar.gz) | ||
curl -L --output "$temp_archive" https://github.com/$DREPO/releases/download/$DVS/cargo-deny-$DVS-$TARGET.tar.gz | ||
tar -xzvf "$temp_archive" -C . --strip-components=1 --wildcards "*/cargo-deny" | ||
- name: cargo-deny check licenses | ||
run: ./cargo-deny -L debug check license | ||
- name: cargo-deny check bans | ||
run: ./cargo-deny -L debug check ban | ||
|
||
# Remove this check if you don't publish the crate(s) from this repo | ||
publish-check: | ||
name: Publish Check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
- name: cargo fetch | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fetch | ||
- name: copy README | ||
shell: bash | ||
run: | | ||
cp README.md lib | ||
cp README.md cli | ||
- name: cargo publish lib | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: publish | ||
args: --dry-run --allow-dirty --manifest-path lib/Cargo.toml | ||
- name: cargo publish cli | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: publish | ||
args: --dry-run --allow-dirty --manifest-path cli/Cargo.toml | ||
|
||
# Remove this job if you don't publish the crate(s) from this repo | ||
# You must add a crates.io API token to your GH secrets called CRATES_IO_TOKEN | ||
publish: | ||
name: Publish | ||
needs: [test, deny-check, publish-check] | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/tags/') | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
override: true | ||
- name: cargo fetch | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fetch | ||
- name: cargo publish | ||
uses: actions-rs/cargo@v1 | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} | ||
with: | ||
command: publish | ||
|
||
# Remove this job if you don't release binaries | ||
# Replace occurances of $BIN_NAME with the name of your binary | ||
release: | ||
name: Release | ||
needs: [test, deny-check] | ||
if: startsWith(github.ref, 'refs/tags/') | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macOS-latest, windows-latest] | ||
include: | ||
- os: ubuntu-latest | ||
rust: stable | ||
target: x86_64-unknown-linux-musl | ||
bin: $BIN_NAME | ||
# We don't enable the progress feature when targeting | ||
# musl since there are some dependencies on shared libs | ||
features: "" | ||
- os: windows-latest | ||
rust: stable | ||
target: x86_64-pc-windows-msvc | ||
bin: $BIN_NAME.exe | ||
features: --features=progress | ||
- os: macOS-latest | ||
rust: stable | ||
target: x86_64-apple-darwin | ||
bin: $BIN_NAME | ||
features: --features=progress | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Install stable toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
override: true | ||
target: ${{ matrix.target }} | ||
- name: Install musl tools | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get install -y musl-tools | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
- name: cargo fetch | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: fetch | ||
args: --target ${{ matrix.target }} | ||
- name: Release build | ||
uses: actions-rs/cargo@v1 | ||
if: matrix.os != 'ubuntu-latest' | ||
with: | ||
command: build | ||
args: --release --target ${{ matrix.target }} ${{ matrix.features }} | ||
- name: Package | ||
shell: bash | ||
run: | | ||
name=$BIN_NAME | ||
tag=$(git describe --tags --abbrev=0) | ||
release_name="$name-$tag-${{ matrix.target }}" | ||
release_tar="${release_name}.tar.gz" | ||
mkdir "$release_name" | ||
if [ "${{ matrix.target }}" != "x86_64-pc-windows-msvc" ]; then | ||
strip "target/${{ matrix.target }}/release/${{ matrix.bin }}" | ||
fi | ||
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "$release_name/" | ||
cp README.md LICENSE-APACHE LICENSE-MIT "$release_name/" | ||
tar czvf "$release_tar" "$release_name" | ||
rm -r "$release_name" | ||
# Windows environments in github actions don't have the gnu coreutils installed, | ||
# which includes the shasum exe, so we just use powershell instead | ||
if [ "${{ matrix.os }}" == "windows-latest" ]; then | ||
echo "(Get-FileHash \"${release_tar}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_tar}.sha256\"" | pwsh -c - | ||
else | ||
echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256" | ||
fi | ||
- name: Publish | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
files: '$BIN_NAME*' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Oops, something went wrong.