Skip to content

Commit 9f11c43

Browse files
github: ci: Add deployment
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent 8839bbd commit 9f11c43

File tree

1 file changed

+77
-3
lines changed

1 file changed

+77
-3
lines changed

.github/workflows/ci.yml

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
name: Cargo Build & Test
1+
name: Build, Test, and Release
22

33
on:
4-
push:
4+
workflow_dispatch:
55
pull_request:
6+
push:
7+
8+
permissions:
9+
contents: write
610

7-
env:
11+
env:
812
CARGO_TERM_COLOR: always
913

1014
jobs:
@@ -41,4 +45,74 @@ jobs:
4145
- run: cargo clippy --tests -- --deny warnings
4246
- run: cargo test --verbose
4347

48+
release:
49+
name: Build Release Binaries and Upload Artifacts
50+
runs-on: ${{ matrix.os }}
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
include:
55+
- os: ubuntu-latest
56+
target: x86_64-unknown-linux-gnu
57+
use_cross: true
58+
ext: ""
59+
- os: ubuntu-latest
60+
target: aarch64-unknown-linux-gnu
61+
use_cross: true
62+
ext: ""
63+
- os: ubuntu-latest
64+
target: armv7-unknown-linux-gnueabihf
65+
use_cross: true
66+
ext: ""
67+
- os: macos-latest
68+
target: aarch64-apple-darwin
69+
use_cross: false
70+
ext: ""
71+
- os: macos-latest
72+
target: x86_64-apple-darwin
73+
use_cross: false
74+
ext: ""
75+
- os: windows-latest
76+
target: x86_64-pc-windows-msvc
77+
use_cross: false
78+
ext: ".exe"
79+
steps:
80+
- name: Check out source
81+
uses: actions/checkout@v4
82+
83+
- name: Install Rust toolchain
84+
uses: dtolnay/rust-toolchain@stable
85+
with:
86+
targets: ${{ matrix.target }}
87+
88+
- name: Install cross
89+
if: matrix.use_cross
90+
run: cargo install cross
91+
92+
- name: Build release binary with cross
93+
if: matrix.use_cross
94+
run: cross build --release --target ${{ matrix.target }}
95+
96+
- name: Build release binary with cargo
97+
if: ${{ !matrix.use_cross }}
98+
run: cargo build --release --target ${{ matrix.target }}
99+
100+
- name: Upload build as workflow artifact
101+
uses: actions/upload-artifact@v4
102+
with:
103+
name: disktest-${{ matrix.target }}${{ matrix.ext }}
104+
path: target/${{ matrix.target }}/release/disktest${{ matrix.ext }}
105+
if-no-files-found: error
106+
107+
- name: Rename artifact
108+
shell: bash
109+
run: mv target/${{ matrix.target }}/release/disktest${{ matrix.ext }} disktest-${{ matrix.target }}${{ matrix.ext }}
110+
111+
- name: Attach artifacts to GitHub release
112+
if: startsWith(github.ref, 'refs/tags/')
113+
uses: softprops/action-gh-release@v2
114+
with:
115+
files: disktest-${{ matrix.target }}${{ matrix.ext }}
116+
token: ${{ secrets.GITHUB_TOKEN }}
117+
44118
# vim: ts=2 sw=2 expandtab

0 commit comments

Comments
 (0)