Skip to content

Commit ea8d789

Browse files
committed
workflows: add ci and release
1 parent 3ac658d commit ea8d789

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
check:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Format
22+
run: cargo fmt --all -- --check
23+
24+
- name: Clippy
25+
run: cargo clippy --all-targets --workspace -- -D warnings
26+
27+
unit:
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
matrix:
31+
os:
32+
- ubuntu-latest
33+
- macos-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- name: Test
37+
run: cargo test --all-targets --workspace
38+
env:
39+
RUST_LOG: DEBUG
40+
RUST_BACKTRACE: full

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
RUST_BACKTRACE: 1
11+
12+
jobs:
13+
build:
14+
name: Build ${{ matrix.target }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: ubuntu-latest
21+
target: x86_64-unknown-linux-musl
22+
artifact_name: cloud-cli
23+
asset_name: cloud-cli-linux-amd64
24+
use_cross: true
25+
- os: ubuntu-latest
26+
target: aarch64-unknown-linux-gnu
27+
artifact_name: cloud-cli
28+
asset_name: cloud-cli-linux-arm64
29+
use_cross: true
30+
31+
steps:
32+
- uses: actions/checkout@v3
33+
34+
- name: Setup Rust toolchain
35+
uses: dtolnay/rust-toolchain@stable
36+
with:
37+
targets: ${{ matrix.target }}
38+
39+
- name: Install cross
40+
run: cargo install cross
41+
42+
- name: Build with Cross
43+
run: cross build --release --target ${{ matrix.target }}
44+
45+
- name: Prepare artifacts
46+
shell: bash
47+
run: |
48+
mkdir -p dist
49+
cp "target/${{ matrix.target }}/release/${{ matrix.artifact_name }}" "dist/${{ matrix.asset_name }}"
50+
chmod +x "dist/${{ matrix.asset_name }}"
51+
52+
- name: Upload artifacts
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{ matrix.asset_name }}
56+
path: dist/${{ matrix.asset_name }}
57+
if-no-files-found: error
58+
59+
release:
60+
name: Create Release
61+
needs: build
62+
runs-on: ubuntu-latest
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v3
66+
67+
- name: Download all artifacts
68+
uses: actions/download-artifact@v4
69+
with:
70+
path: artifacts
71+
72+
- name: Create Release
73+
id: create_release
74+
uses: softprops/action-gh-release@v1
75+
with:
76+
files: artifacts/**/*
77+
draft: false
78+
prerelease: false
79+
generate_release_notes: true
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)