Skip to content

Add release workflow #5

Add release workflow

Add release workflow #5

name: Build and release
on:
push:
branches:
- main
- master
tags:
- '*'
pull_request:
workflow_dispatch:
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Build
run: cargo build --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: linux-binary
path: target/release/via-cli
build-windows:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Build
run: cargo build --release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows-binary
path: target/release/via-cli.exe
create-release:
runs-on: ubuntu-latest
needs: [build-linux, build-windows]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: linux-binary
path: ./artifacts
- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: windows-binary
path: ./artifacts
- name: Create release draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
"./artifacts/via-cli.exe" \
"./artifacts/via-cli" \
--draft \
--title "${{ github.ref_name }}"