Skip to content

Commit

Permalink
ci: add build and release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter committed May 25, 2024
1 parent 27d7554 commit cfeff4d
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
rustflags = ["-Ctarget-cpu=native"]
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build

on:
workflow_call:
workflow_dispatch:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
strategy:
matrix:
target:
- aarch64-apple-darwin
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-musl
include:
- target: aarch64-apple-darwin
runner: macos-14
- target: x86_64-apple-darwin
runner: macos-latest
- target: x86_64-pc-windows-msvc
runner: windows-latest
- target: aarch64-unknown-linux-musl
runner: ubuntu-latest
- target: x86_64-unknown-linux-musl
runner: ubuntu-latest
fail-fast: false
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.target }}

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2

- name: Build
run: cargo build --release --locked --target ${{ matrix.target }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
if-no-files-found: "error"
name: purr-${{ matrix.target }}
path: |
./target/${{ matrix.target }}/release/purr${{ contains(matrix.target, 'windows') && '.exe' || '' }}
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Release

on:
push:
tags: ["v*.*.*"]

jobs:
check:
uses: ./.github/workflows/check.yml

build:
uses: ./.github/workflows/build.yml

publish:
needs: [check, build]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2

- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}

release:
needs: [publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.21

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Generate release notes
run: bunx changelogithub@latest --output CHANGELOG.txt

- name: Create release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.txt
files: artifacts/**/*
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ url = "2.5.0"
[lints.clippy]
all = "warn"
pedantic = "warn"

[profile.release]
lto = "fat"
strip = "symbols"
codegen-units = 1
opt-level = "z"
panic = "abort"

0 comments on commit cfeff4d

Please sign in to comment.