Skip to content

Commit b74d989

Browse files
committed
chore: add workflows for ci and release
1 parent 8ba948a commit b74d989

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
checks:
14+
name: Checks
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Install Rust toolchain
22+
uses: dtolnay/rust-toolchain@stable
23+
with:
24+
components: rustfmt, clippy
25+
26+
- name: Cache Rust build artifacts
27+
uses: Swatinem/rust-cache@v2
28+
29+
- name: Check formatting
30+
run: cargo fmt --all --check
31+
32+
- name: Run Clippy
33+
run: cargo clippy --all-targets --all-features -- -D warnings
34+
35+
- name: Run tests
36+
run: cargo test --all-targets --all-features

.github/workflows/release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
build:
13+
name: Build ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os:
19+
- ubuntu-latest
20+
- macos-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Install Rust toolchain
27+
uses: dtolnay/rust-toolchain@stable
28+
29+
- name: Cache Rust build artifacts
30+
uses: Swatinem/rust-cache@v2
31+
32+
- name: Compute artifact names
33+
shell: bash
34+
run: |
35+
echo "TARGET=$(rustc -vV | sed -n 's/^host: //p')" >> "$GITHUB_ENV"
36+
echo "VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
37+
38+
- name: Build release binary
39+
run: cargo build --locked --release
40+
41+
- name: Package release archive
42+
shell: bash
43+
run: |
44+
ARCHIVE_BASENAME="hue-${VERSION}-${TARGET}"
45+
rm -rf dist
46+
mkdir -p dist
47+
cp target/release/hue "dist/hue"
48+
cp README.md "dist/README.md"
49+
50+
tar -C dist -czf "${ARCHIVE_BASENAME}.tar.gz" .
51+
shasum -a 256 "${ARCHIVE_BASENAME}.tar.gz" > "${ARCHIVE_BASENAME}.tar.gz.sha256"
52+
53+
- name: Upload release artifacts
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: release-${{ env.TARGET }}
57+
path: |
58+
hue-${{ env.VERSION }}-${{ env.TARGET }}.tar.gz
59+
hue-${{ env.VERSION }}-${{ env.TARGET }}.tar.gz.sha256
60+
61+
publish:
62+
name: Publish GitHub release
63+
runs-on: ubuntu-latest
64+
needs: build
65+
permissions:
66+
contents: write
67+
68+
steps:
69+
- name: Download release artifacts
70+
uses: actions/download-artifact@v4
71+
with:
72+
path: release-artifacts
73+
pattern: release-*
74+
merge-multiple: true
75+
76+
- name: Publish release
77+
uses: softprops/action-gh-release@v2
78+
with:
79+
files: release-artifacts/*
80+
generate_release_notes: true

0 commit comments

Comments
 (0)