CI: Add Caching #14
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: Rust Binary Release | |
on: | |
push: | |
jobs: | |
build: | |
name: Build Rust Binary Releases | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cache Cargo | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Install Rust toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- name: Build | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: Package Artifacts | |
run: | | |
mkdir artifacts | |
cp target/${{ matrix.target }}/release/${{ env.PROJECT_NAME }} artifacts/ | |
# Zip artifacts for Windows | |
if [ "${{ matrix.os }}" == "windows-latest" ]; then | |
7z a artifacts.zip artifacts/ | |
else | |
tar -czvf artifacts.tar.gz artifacts/ | |
fi | |
shell: bash | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.os }} | |
path: ./artifacts.* | |
env: | |
PROJECT_NAME: quicssh | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v2 | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Release | |
uses: marvinpinto/action-automatic-releases@latest | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
automatic_release_tag: latest | |
prerelease: false | |
title: Latest Release | |
files: | | |
* |