Skip to content

Commit 79d1b84

Browse files
authored
Merge pull request #1 from stslex/dev
Init daemon
2 parents 5c472e3 + f7681e4 commit 79d1b84

16 files changed

Lines changed: 906 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Rust Build
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches: ["dev, master"]
7+
workflow_dispatch:
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
19+
- name: Build
20+
run: cargo build --verbose
21+
22+
- name: Run tests
23+
run: cargo test --verbose
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build Dev
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
build:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- os: ubuntu-latest
18+
target: x86_64-unknown-linux-gnu
19+
suffix: linux-amd64
20+
- os: ubuntu-latest
21+
target: aarch64-unknown-linux-gnu
22+
suffix: linux-arm64
23+
use_cross: true
24+
- os: macos-latest
25+
target: x86_64-apple-darwin
26+
suffix: macos-amd64
27+
- os: macos-latest
28+
target: aarch64-apple-darwin
29+
suffix: macos-arm64
30+
- os: windows-latest
31+
target: x86_64-pc-windows-msvc
32+
suffix: windows-amd64
33+
bin_ext: .exe
34+
35+
runs-on: ${{ matrix.os }}
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Extract version
41+
id: meta
42+
shell: bash
43+
run: |
44+
VERSION=$(grep '^version' splitway-daemon/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
47+
PR="${{ github.event.pull_request.number }}"
48+
if [ -n "$PR" ]; then
49+
echo "label=v${VERSION}_dev_pr-${PR}" >> $GITHUB_OUTPUT
50+
else
51+
echo "label=v${VERSION}_dev" >> $GITHUB_OUTPUT
52+
fi
53+
54+
- uses: dtolnay/rust-toolchain@stable
55+
with:
56+
targets: ${{ matrix.target }}
57+
58+
- name: Install cross
59+
if: ${{ matrix.use_cross == true }}
60+
uses: taiki-e/install-action@v2
61+
with:
62+
tool: cross
63+
64+
- name: Build (cross)
65+
if: ${{ matrix.use_cross == true }}
66+
run: cross build --release -p splitway-daemon --target ${{ matrix.target }}
67+
68+
- name: Build (cargo)
69+
if: ${{ matrix.use_cross != true }}
70+
run: cargo build --release -p splitway-daemon --target ${{ matrix.target }}
71+
72+
- uses: actions/upload-artifact@v4
73+
with:
74+
name: splitway-daemon-${{ steps.meta.outputs.label }}-${{ matrix.suffix }}
75+
path: target/${{ matrix.target }}/release/splitway-daemon${{ matrix.bin_ext }}

.github/workflows/release.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Build release daemon
2+
3+
on:
4+
push:
5+
branches: ["master"]
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build:
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
include:
18+
- os: ubuntu-latest
19+
target: x86_64-unknown-linux-gnu
20+
suffix: linux-amd64
21+
- os: ubuntu-latest
22+
target: aarch64-unknown-linux-gnu
23+
suffix: linux-arm64
24+
use_cross: true
25+
- os: macos-latest
26+
target: x86_64-apple-darwin
27+
suffix: macos-amd64
28+
- os: macos-latest
29+
target: aarch64-apple-darwin
30+
suffix: macos-arm64
31+
- os: windows-latest
32+
target: x86_64-pc-windows-msvc
33+
suffix: windows-amd64
34+
bin_ext: .exe
35+
36+
runs-on: ${{ matrix.os }}
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- name: Extract version
42+
id: meta
43+
shell: bash
44+
run: |
45+
VERSION=$(grep '^version' splitway-daemon/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
46+
echo "version=$VERSION" >> $GITHUB_OUTPUT
47+
48+
- uses: dtolnay/rust-toolchain@stable
49+
with:
50+
targets: ${{ matrix.target }}
51+
52+
- name: Install cross
53+
if: ${{ matrix.use_cross == true }}
54+
uses: taiki-e/install-action@v2
55+
with:
56+
tool: cross
57+
58+
- name: Build (cross)
59+
if: ${{ matrix.use_cross == true }}
60+
run: cross build --release -p splitway-daemon --target ${{ matrix.target }}
61+
62+
- name: Build (cargo)
63+
if: ${{ matrix.use_cross != true }}
64+
run: cargo build --release -p splitway-daemon --target ${{ matrix.target }}
65+
66+
- name: Rename binary
67+
shell: bash
68+
run: |
69+
src="target/${{ matrix.target }}/release/splitway-daemon${{ matrix.bin_ext }}"
70+
dst="splitway-daemon-${{ matrix.suffix }}${{ matrix.bin_ext }}"
71+
cp "$src" "$dst"
72+
73+
- uses: actions/upload-artifact@v4
74+
with:
75+
name: splitway-daemon-${{ matrix.suffix }}
76+
path: splitway-daemon-${{ matrix.suffix }}${{ matrix.bin_ext }}
77+
78+
release:
79+
needs: build
80+
runs-on: ubuntu-latest
81+
82+
permissions:
83+
contents: write
84+
85+
steps:
86+
- uses: actions/checkout@v4
87+
88+
- name: Extract version
89+
id: meta
90+
shell: bash
91+
run: |
92+
VERSION=$(grep '^version' splitway-daemon/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
93+
echo "version=$VERSION" >> $GITHUB_OUTPUT
94+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
95+
96+
- uses: actions/download-artifact@v4
97+
with:
98+
path: artifacts
99+
merge-multiple: true
100+
101+
- name: Create release
102+
uses: softprops/action-gh-release@v2
103+
with:
104+
tag_name: ${{ steps.meta.outputs.tag }}
105+
name: ${{ steps.meta.outputs.tag }}
106+
files: artifacts/*
107+
fail_on_unmatched_files: true
108+
109+
bump-version:
110+
needs: release
111+
runs-on: ubuntu-latest
112+
113+
permissions:
114+
contents: write
115+
116+
steps:
117+
- uses: actions/checkout@v4
118+
119+
- name: Bump patch version in Cargo.toml files
120+
shell: bash
121+
run: |
122+
VERSION=$(grep '^version' splitway-daemon/Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
123+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
124+
MINOR=$(echo "$VERSION" | cut -d. -f2)
125+
PATCH=$(echo "$VERSION" | cut -d. -f3)
126+
NEW_PATCH=$((PATCH + 1))
127+
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
128+
sed -i "s/^version = \"$VERSION\"/version = \"$NEW_VERSION\"/" splitway-daemon/Cargo.toml
129+
echo "Bumped $VERSION -> $NEW_VERSION"
130+
131+
- name: Commit and push version bump
132+
shell: bash
133+
run: |
134+
git config user.name "github-actions[bot]"
135+
git config user.email "github-actions[bot]@users.noreply.github.com"
136+
git add splitway-daemon/Cargo.toml
137+
git commit -m "chore: bump version after release"
138+
git push

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Added by cargo
2+
/target

0 commit comments

Comments
 (0)