Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
246 changes: 11 additions & 235 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,245 +1,21 @@
name: CI

on:
push:
paths-ignore:
- '.github/**'
- 'ci/**'
- 'examples/**'
- '**.md'
branches: ['**']
pull_request:
paths-ignore:
- '.github/**'
- 'ci/**'
- 'examples/**'
- '**.md'
workflow_dispatch:

name: CI

env:
BREW_REPO: jmgilman/homebrew-apps
RUST_TOOLCHAIN: stable
TOOLCHAIN_PROFILE: minimal

jobs:
check:
name: Run cargo check
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Load cache
uses: actions/cache@v2
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@1.90.0
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

lints:
name: Run cargo fmt and cargo clippy
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Load cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
components: rustfmt, clippy
- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
test:
name: Run cargo test
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Load cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- name: Run cargo test
uses: actions-rs/cargo@v1
env:
RUST_TEST_THREADS: 1
with:
command: test
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags/v')
needs: [test, lints, check]
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: ${{ env.TOOLCHAIN_PROFILE }}
toolchain: ${{ env.RUST_TOOLCHAIN }}
override: true
- uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
build:
name: Build binaries
runs-on: ${{ matrix.job.os }}
if: startsWith(github.event.ref, 'refs/tags/v')
needs: [test, lints, check]
strategy:
matrix:
job:
- { os: ubuntu-20.04, target: aarch64-unknown-linux-gnu, use-cross: true }
- { os: macos-10.15 , target: x86_64-apple-darwin }
- { os: windows-2019, target: x86_64-pc-windows-msvc }
- { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu }
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
target: ${{ matrix.job.target }}
override: true
profile: ${{ env.TOOLCHAIN_PROFILE }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --release --target=${{ matrix.job.target }}
- name: Archive build result
if: startsWith(matrix.job.os, 'ubuntu') || startsWith(matrix.job.os, 'macos')
run: tar -czvf target/${{ matrix.job.target }}.tar.gz target/${{ matrix.job.target }}/release/vssh
- name: Zip build result
if: startsWith(matrix.job.os, 'windows')
run: 7z a -tzip target/${{ matrix.job.target }}.zip target/${{ matrix.job.target }}/release/vssh.exe
- name: Upload build result as artifact
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: target/${{ matrix.job.target }}.*
release:
name: Create release
runs-on: ubuntu-latest
needs: [test, lints, check, build]
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Create release directory
run: mkdir release
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build-artifacts
path: release
- name: Generate checksum
uses: jmgilman/actions-generate-checksum@v1
with:
patterns: |
release/*.zip
release/*.tar.gz
- name: Create release with artifact
uses: softprops/action-gh-release@v1
with:
files: |
release/*
checksum.txt
brew:
name: Push updated Homebrew formula
runs-on: ubuntu-latest
needs: [test, lints, check, build, release]
if: startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Set version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Set repo name
id: repo-name
run: echo "::set-output name=value::$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')"
- name: Fetch checksum file
uses: dsaltares/fetch-gh-release-asset@master
with:
file: checksum.txt
target: checksum.txt
version: tags/${{ env.RELEASE_VERSION }}
- name: Fetch checksums
id: checksums
run: |
APPLE=$(cat checksum.txt | grep release/x86_64-apple-darwin.tar.gz | cut -d " " -f 1)
LINUX=$(cat checksum.txt | grep release/x86_64-unknown-linux-gnu.tar.gz | cut -d " " -f 1)

echo "::set-output name=sha256_apple::$APPLE"
echo "::set-output name=sha256_linux::$LINUX"
- name: Build formula
uses: cuchi/jinja2-action@v1.2.0
with:
template: ci/brew.rb.j2
output_file: ${{ steps.repo-name.outputs.value }}.rb
strict: true
variables: |
SHA256_APPLE=${{ steps.checksums.outputs.sha256_apple }}
SHA256_LINUX=${{ steps.checksums.outputs.sha256_linux }}
VERSION=${{ env.RELEASE_VERSION }}
- name: Encode formula with base64
id: encode
run: |
BASE64=$(base64 -w 0 ${{ steps.repo-name.outputs.value }}.rb)
echo "::set-output name=base64::$BASE64"
- name: Dispatch update to homebrew tap repository
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
repository: ${{ env.BREW_REPO }}
event-type: update
client-payload: |
{
"content": "${{ steps.encode.outputs.base64 }}",
"name": "${{ steps.repo-name.outputs.value }}",
"version": "${{ env.RELEASE_VERSION }}"
}
- name: Upload formula as artifact
uses: actions/upload-artifact@v2
with:
name: formula
path: ${{ steps.repo-name.outputs.value }}.rb
- run: cargo check --locked
- run: cargo fmt --all -- --check
- run: cargo clippy --locked -- -D warnings
- name: Run unit tests
run: cargo test --locked --bin vssh
Loading