Version Packages #45
Workflow file for this run
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
name: Release | |
on: | |
push: | |
tags: ["v*"] | |
# on PRs only build and test. Does not upload artifacts anywhere. | |
pull_request: | |
branches: ["main"] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
name: Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-musl # for cargo | |
release_name: linux_amd64 | |
os: ubuntu-latest | |
- target: aarch64-unknown-linux-musl | |
release_name: linux_arm64 | |
os: ubuntu-latest | |
- target: x86_64-apple-darwin | |
release_name: darwin_amd64 | |
os: macos-latest | |
- target: aarch64-apple-darwin | |
release_name: darwin_arm64 | |
os: macos-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: FranzDiebold/github-env-vars-action@v2.3.1 | |
- name: Install coreutils for macOS | |
if: matrix.os == 'macos-latest' | |
run: brew install coreutils | |
# Cache files between builds | |
- name: Setup | Cache Cargo | |
uses: actions/cache@v2.1.7 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Setup | Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: nightly | |
profile: minimal | |
target: ${{ matrix.target }} | |
override: true | |
- name: Build release | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --target ${{ matrix.target }} --release | |
use-cross: ${{ matrix.os == 'ubuntu-latest' }} | |
- name: Copy and rename utility | |
run: cp target/${{ matrix.target }}/release/ny ny | |
- name: Create archive | |
run: | | |
tar -czvf ny_${{ matrix.target }}.tar.gz ny | |
- name: Upload artifacts archive | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ny_${{ matrix.release_name }}.tar.gz | |
path: ny_${{ matrix.target }}.tar.gz | |
- name: Upload binary to release | |
if: ${{ startsWith(github.ref, 'refs/tags/v') }} | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ny_${{ matrix.target }}.tar.gz | |
asset_name: ny_${{ matrix.release_name }}.tar.gz | |
tag: ${{ github.ref }} | |
overwrite: true |