Skip to content

Commit

Permalink
Improve the GitHub workflows. (#1)
Browse files Browse the repository at this point in the history
- Add more OS/toolchains to the CI workflow
- Create a release workflow to create pre-built binaries for Mac, Linux, Windows (all x86_64) and posts them as a draft "release"
  • Loading branch information
alirez authored Mar 14, 2021
1 parent c7e89f4 commit 97a51b3
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 2 deletions.
45 changes: 43 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,51 @@ env:
jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

strategy:
matrix:
build:
- pinned
- stable
- beta
- nightly
- macos
- win-msvc
- win-gnu

include:
- build: pinned
os: ubuntu-latest
rust: 1.50.0
- build: stable
os: ubuntu-latest
rust: stable
- build: beta
os: ubuntu-latest
rust: beta
- build: nightly
os: ubuntu-latest
rust: nightly
- build: macos
os: macos-latest
rust: nightly
- build: win-msvc
os: windows-latest
rust: nightly
- build: win-gnu
os: windows-2019
rust: nightly-x86_64-gnu

steps:
- uses: actions/checkout@v2
- name: Checkout reopository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
- name: Build
run: cargo build --verbose
- name: Run tests
Expand Down
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release pre-built binaries

on:
push:
tags:
- 'v*'

env:
CARGO_TERM_COLOR: always

jobs:
create_release:
runs-on: ubuntu-latest
steps:
- name: create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}

build_linux:
runs-on: ubuntu-latest
needs: create_release
steps:
- uses: actions/checkout@v1
- name: build
run: cargo build --verbose --release
- name: stirp symbols and rename
run: |
strip target/release/snifos
cp target/release/snifos ./snifos
gzip snifos
- name: upload release asset (x86_64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./snifos.gz
asset_name: snifos-x86_64-unknown-linux-gnu.gz
asset_content_type: application/gzip

build_windows:
runs-on: windows-latest
needs: create_release
steps:
- uses: actions/checkout@v1
- name: build
run: cargo build --verbose --release
- name: strip symbols
run: strip target/release/snifos.exe
- name: compress
run: Compress-Archive -LiteralPath target/release/snifos.exe -DestinationPath snifos.zip
- name: upload release asset (Windows)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_name: snifos-x86_64-pc-windows-msvc.zip
asset_path: snifos.zip
asset_content_type: application/zip

build_macos:
runs-on: macos-latest
needs: create_release
steps:
- uses: actions/checkout@v1
- name: build
run: cargo build --verbose --release
- name: strip symbols
run: strip target/release/snifos
- name: compress
run: gzip -c target/release/snifos > ./snifos.gz
- name: upload release asset (Darwin)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./snifos.gz
asset_name: snifos-x86_64-apple-darwin.gz
asset_content_type: application/gzip

0 comments on commit 97a51b3

Please sign in to comment.