Skip to content

Commit

Permalink
chore: add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
fgardt committed Mar 13, 2024
1 parent f6cc734 commit 111e084
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2

updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: "weekly"
target-branch: "main"
commit-message:
prefix: "deps(cargo)"

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "weekly"
target-branch: "main"
commit-message:
prefix: "deps(ci)"
75 changes: 75 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: release

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

jobs:
release_build:
name: Build ${{ matrix.platform.os_name }}
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
platform:
- os_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-gnu
archiver: zip
archive_type: zip
bin: spritter.exe
- os_name: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archiver: tar
archive_type: tar.gz
bin: spritter
- os_name: MacOS-x86_64
os: macos-latest
target: x86_64-apple-darwin
archiver: tar
archive_type: tar.gz
bin: spritter
- os_name: MacOS-aarch64
os: macos-latest
target: aarch64-apple-darwin
archiver: tar
archive_type: tar.gz
bin: spritter
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Stable rust toolchain
run: rustup toolchain install stable --target ${{ matrix.platform.target }} --profile minimal
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "rust-stable"
shared-key: "release_build-${{ matrix.platform.target }}"
- name: Build
run: cargo build --target ${{ matrix.platform.target }} --release --package spritter
- name: Archive the built binary
uses: TheDoctor0/zip-release@0.7.6
with:
type: ${{ matrix.platform.archiver }}
filename: spritter_${{ matrix.platform.target }}.${{ matrix.platform.archive_type }}
directory: ./target/${{ matrix.platform.target }}/release
path: ${{ matrix.platform.bin }}
- name: Upload release artifact for release job
uses: actions/upload-artifact@v3
with:
path: ./target/${{ matrix.platform.target }}/release/spritter_${{ matrix.platform.target }}.${{ matrix.platform.archive_type }}
create_release:
name: Create release
needs: release_build
runs-on: ubuntu-latest
steps:
- name: Download release artifacts from build job
uses: actions/download-artifact@v3
with:
path: ~/build_artifacts
- name: Create release
id: create_release
uses: ncipollo/release-action@v1
with:
artifacts: ~/build_artifacts/artifact/*
85 changes: 85 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: rust

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
branches:
- main

jobs:
fmt:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Stable rust toolchain
run: rustup toolchain install stable --profile minimal
- name: Check formatting
run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Stable rust toolchain
run: rustup toolchain install stable --profile minimal
- name: Add Clippy
run: rustup component add clippy
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "rust-stable"
shared-key: "clippy"
- name: Install cargo-binstall
run: wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-gnu.tgz -O - | tar -xz -C $HOME/.cargo/bin
- name: Install sarif-fmt & clippy-sarif
run: cargo binstall --no-confirm --force sarif-fmt clippy-sarif
- name: Run Clippy
run: cargo clippy --message-format=json | clippy-sarif | tee results.sarif | sarif-fmt
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif

build:
name: Build ${{ matrix.platform.os_name }} [rust ${{ matrix.toolchain }}]
runs-on: ${{ matrix.platform.os }}
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
strategy:
matrix:
platform:
- os_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-gnu
- os_name: Linux-x86_64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os_name: MacOS-x86_64
os: macos-latest
target: x86_64-apple-darwin
- os_name: MacOS-aarch64
os: macos-latest
target: aarch64-apple-darwin
toolchain:
- stable
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup ${{ matrix.toolchain }} toolchain
run: rustup toolchain install ${{ matrix.toolchain }} --target ${{ matrix.platform.target }} --profile minimal
- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
prefix-key: "rust-${{ matrix.toolchain }}"
shared-key: "build-${{ matrix.platform.target }}"
- name: Build
run: cargo build --target ${{ matrix.platform.target }}

0 comments on commit 111e084

Please sign in to comment.