Skip to content

Commit fd3abf3

Browse files
committed
ci: Initial GHA pipeline
1 parent ed4eed7 commit fd3abf3

3 files changed

Lines changed: 114 additions & 0 deletions

File tree

.github/workflows/ci-reusable.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
name: Reusable CI workflow
3+
4+
on:
5+
workflow_call:
6+
7+
jobs:
8+
ci:
9+
runs-on: ubuntu-latest
10+
timeout-minutes: 15
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions-rust-lang/setup-rust-toolchain@v1
14+
with:
15+
components: clippy, rustfmt
16+
rustflags: ""
17+
target: x86_64-unknown-linux-gnu
18+
- run: cargo test --all-features
19+
if: always()
20+
- run: cargo fmt --check
21+
if: always()
22+
- run: cargo clippy --all-targets
23+
if: always()
24+
- run: cargo build --release --all-features
25+
if: always()

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: CI
3+
4+
on:
5+
push:
6+
branches:
7+
- '**' # ignore tags - they run CI separately
8+
pull_request:
9+
workflow_dispatch:
10+
11+
jobs:
12+
ci:
13+
uses: ./.github/workflows/ci-reusable.yml

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
preflight:
11+
name: Preflight checks
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Check that tag matches version in Cargo.toml
16+
run: |
17+
version=$(cargo pkgid | cut -d'#' -f2)
18+
if [ "$version" != "${{ github.ref_name }}" ]; then
19+
echo "Tag version does not match Cargo.toml version"
20+
echo "Tag: ${{ github.ref_name }}, Cargo.toml: $version"
21+
exit 1
22+
fi
23+
24+
ci:
25+
name: Run CI
26+
needs: preflight
27+
uses: ./.github/workflows/ci-reusable.yml
28+
29+
release:
30+
needs: ci
31+
runs-on: ${{ matrix.runs-on }}
32+
timeout-minutes: 15
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
include:
37+
- runs-on: ubuntu-latest
38+
target: x86_64-unknown-linux-musl
39+
40+
- runs-on: ubuntu-latest
41+
target: aarch64-unknown-linux-musl
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- uses: actions-rust-lang/setup-rust-toolchain@v1
46+
with:
47+
components: clippy, rustfmt
48+
rustflags: ""
49+
target: ${{ matrix.target }}
50+
51+
- name: Install cross
52+
if: ${{ matrix.runs-on == 'ubuntu-latest' }}
53+
run: cargo install cross --git https://github.com/cross-rs/cross
54+
55+
# This step seems absolutely necessary for 'cross' to work.
56+
- name: Clean build cache
57+
run: cargo clean
58+
59+
- name: Build (Linux, cross compile)
60+
if: ${{ matrix.runs-on == 'ubuntu-latest' }}
61+
run: cross build --release --all-features --target=${{ matrix.target }}
62+
63+
- name: Create a tar.gz (Linux, macOS)
64+
id: create-tar
65+
run: |
66+
mkdir release
67+
cp LICENSE release/
68+
cp target/${{ matrix.target }}/release/cmk-rustik release/
69+
tar -czvf cmk-rustik-${{ github.ref_name }}-${{ matrix.target }}.tar.gz release/
70+
71+
- name: Release
72+
uses: softprops/action-gh-release@v2
73+
if: github.ref_type == 'tag'
74+
with:
75+
files: |
76+
cmk-rustik*.tar.gz

0 commit comments

Comments
 (0)