Skip to content

Commit 23a2b05

Browse files
authored
Reimplement a first version in rust (#2)
Re-implement almost completely in rust --------- Signed-off-by: Marc Schöchlin <[email protected]>
1 parent ef8458c commit 23a2b05

14 files changed

+1905
-62
lines changed

.github/workflows/build-and-run.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Build and Run Project
2+
3+
on:
4+
push:
5+
branches:
6+
- '**' # Run on commits to any branch
7+
8+
jobs:
9+
build-and-run:
10+
uses: ./.github/workflows/common-steps.yml # Reference reusable workflow
11+
with:
12+
build-type: test

.github/workflows/common-steps.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Common Steps
2+
3+
on:
4+
workflow_call: # Enables this workflow to be called by others
5+
inputs:
6+
build-type:
7+
description: "Type of build (e.g., debug, release)"
8+
type: string
9+
required: true
10+
11+
jobs:
12+
common-steps:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
- name: Set up Rust
18+
uses: actions-rs/toolchain@v1
19+
with:
20+
toolchain: stable # or specify the desired version
21+
- name: Build project
22+
run: cargo build --release
23+
- name: Package tarball
24+
run: |
25+
mkdir -p release/hostctl release/hostctl/misc
26+
cp target/release/hostctl release/hostctl/
27+
cp -av recipe release/hostctl/recipe/
28+
target/release/hostctl generate-completions bash > release/hostctl/misc/hostctl_bash_completion.sh
29+
target/release/hostctl generate-completions zsh > release/hostctl/misc/hostctl_zsh_completion.sh
30+
target/release/hostctl generate-completions fish > release/hostctl/misc/hostctl_fish_completion.sh
31+
cd release
32+
tar -czvf ../hostctl-v${{ github.ref_name }}.tar.gz hostctl
33+
tar tzvf ../hostctl-v${{ github.ref_name }}.tar.gz
34+
- name: Upload tarball as release asset
35+
if: ${{ inputs.build-type == 'release' }}
36+
uses: actions/upload-release-asset@v1
37+
with:
38+
upload_url: ${{ github.event.release.upload_url }}
39+
asset_path: ./hostctl-v${{ github.ref_name }}.tar.gz
40+
asset_name: hostctl-v${{ github.ref_name }}.tar.gz
41+
asset_content_type: application/gzip

.github/workflows/release-tarball.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Release Tarball
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger only on version tags (e.g., v1.0.0)
7+
8+
jobs:
9+
release:
10+
uses: ./.github/workflows/common-steps.yml # Reference reusable workflow
11+
with:
12+
build-type: release

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

0 commit comments

Comments
 (0)