Skip to content

Build and Release

Build and Release #60

Workflow file for this run

name: Build and Release
on:
push:
paths:
- Cargo.toml
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build:
environment: build_env
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- run: export SUPABASE_URL=${{ secrets.SUPABASE_URL }}
- run: export SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}
- uses: actions/checkout@v3
- name: Build
run: cargo build -r
- name: Get version from cargo.toml for windows
if: matrix.os == 'windows-latest'
env:
version: $(Get-Content Cargo.toml | Select-String -Pattern 'version =' | Select-Object -First 1 | ForEach-Object { $_.ToString().Split(' ')[2].Trim('"') })
run: |
echo "version=${{ env.version }}" >> $GITHUB_ENV
- name: Get version from cargo.toml for linux and macos
if: matrix.os != 'windows-latest'
run: |
echo "version=$(sed -n 's/version = "\(.*\)"/\1/p' Cargo.toml | head -1)" >> $GITHUB_ENV
- name: Upload artifacts for windows
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: rust-kanban-${{ matrix.os }}
path: target/release/rust-kanban.exe
- name: Upload artifacts for linux and macos
if: matrix.os != 'windows-latest'
uses: actions/upload-artifact@v3
with:
name: rust-kanban-${{ matrix.os }}
path: target/release/rust-kanban
release:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get version from Cargo.toml
run: |
echo "version=$(sed -n 's/version = "\(.*\)"/\1/p' Cargo.toml | head -1)" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: rust-kanban-windows-latest
path: windows
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: rust-kanban-ubuntu-latest
path: linux
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: rust-kanban-macos-latest
path: macos
- name: Rename files
run: |
mv windows/rust-kanban.exe "windows/rust-kanban-Windows-v${{ env.version }}.exe"
mv linux/rust-kanban "linux/rust-kanban-Linux-v${{ env.version }}"
mv macos/rust-kanban "macos/rust-kanban-MacOS-v${{ env.version }}"
- name: Create Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "v${{ env.version }}"
prerelease: true
title: "Development Build"
files: |
/home/runner/work/rust_kanban/rust_kanban/linux
/home/runner/work/rust_kanban/rust_kanban/windows
/home/runner/work/rust_kanban/rust_kanban/macos
- name: prepare for publishing
run: |
rm -rf "linux/rust-kanban-Linux-v${{ env.version }}"
rm -rf "macos/rust-kanban-MacOS-v${{ env.version }}"
rm -rf "windows/rust-kanban-Windows-v${{ env.version }}.exe"
- uses: katyo/publish-crates@v2
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}