Skip to content

Commit 7830a8f

Browse files
committed
🐛 Fix configuration being overwritten and improve CI process
1 parent 4e16456 commit 7830a8f

File tree

19 files changed

+661
-298
lines changed

19 files changed

+661
-298
lines changed

.github/actions/setup/action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 'Setup'
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Install Rust Toolchain Components
7+
uses: dtolnay/rust-toolchain@stable
8+
with:
9+
toolchain: stable
10+
target: ${{ matrix.target }}
11+
12+
- name: Install just
13+
uses: extractions/setup-just@v2
14+
15+
- name: Install cross
16+
uses: taiki-e/install-action@v2
17+
with:
18+
tool: cross
19+
20+
- name: Install cargo-edit
21+
uses: baptiste0928/cargo-install@v3
22+
with:
23+
crate: cargo-edit
24+
25+
- name: Install patch-crate
26+
uses: baptiste0928/cargo-install@v3
27+
with:
28+
crate: patch-crate

.github/workflows/build.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# .github/workflows/build.yml
2+
name: Build
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
version:
8+
type: string
9+
required: false
10+
features:
11+
type: string
12+
required: false
13+
default: default
14+
description: Space or comma separated list of features to activate
15+
prerelease:
16+
type: boolean
17+
description: "Identify the release as a prerelease. Defaults to false"
18+
required: false
19+
20+
workflow_dispatch:
21+
inputs:
22+
features:
23+
type: string
24+
required: false
25+
default: default
26+
description: Space or comma separated list of features to activate
27+
28+
29+
jobs:
30+
build:
31+
name: build ${{ matrix.target }} ${{ inputs.version }}
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
include:
36+
- target: x86_64-pc-windows-msvc
37+
os: windows-latest
38+
archive: zip
39+
- target: x86_64-pc-windows-gnu
40+
os: windows-latest
41+
archive: zip
42+
- target: aarch64-pc-windows-msvc
43+
os: windows-latest
44+
archive: zip
45+
- target: i686-pc-windows-msvc
46+
os: windows-latest
47+
archive: zip
48+
# - target: i686-pc-windows-gnu # error: linker `i686-w64-mingw32-gcc` not found
49+
# os: windows-latest
50+
# archive: zip
51+
- target: x86_64-apple-darwin
52+
os: macos-latest
53+
archive: zip
54+
- target: aarch64-apple-darwin
55+
os: macos-latest
56+
archive: zip
57+
- target: aarch64-unknown-linux-gnu
58+
os: ubuntu-latest
59+
archive: tar.gz tar.xz tar.zst
60+
- target: aarch64-unknown-linux-musl
61+
os: ubuntu-latest
62+
archive: tar.gz tar.xz tar.zst
63+
# - target: arch64-unknown-linux-musl
64+
# archive: tar.gz tar.xz tar.zst
65+
- target: x86_64-unknown-linux-musl
66+
os: ubuntu-latest
67+
archive: tar.gz tar.xz tar.zst
68+
- target: x86_64-unknown-linux-gnu
69+
os: ubuntu-latest
70+
archive: tar.gz tar.xz tar.zst
71+
- target: arm-unknown-linux-musleabi
72+
os: ubuntu-latest
73+
archive: tar.gz tar.xz tar.zst
74+
- target: arm-unknown-linux-musleabihf
75+
os: ubuntu-latest
76+
archive: tar.gz tar.xz tar.zst
77+
# - target: mips-unknown-linux-musl
78+
# archive: tar.gz tar.xz tar.zst
79+
# - target: mips-unknown-linux-musl
80+
# archive: tar.gz tar.xz tar.zst
81+
# - target: mips64-unknown-linux-muslabi64
82+
# archive: tar.gz tar.xz tar.zst
83+
- target: aarch64-linux-android
84+
os: ubuntu-latest
85+
archive: tar.gz tar.xz tar.zst
86+
# - target: x86_64-unknown-freebsd
87+
# os: ubuntu-latest
88+
# archive: tar.gz tar.xz tar.zst
89+
# - target: x86_64-unknown-netbsd
90+
# os: ubuntu-latest
91+
# archive: tar.gz tar.xz tar.zst
92+
# - target: wasm32-unknown-emscripten
93+
# archive: tar.gz tar.xz tar.zst
94+
95+
runs-on: ${{matrix.os}}
96+
env:
97+
DIST_DIR: zerotier-edge-${{ matrix.target }}
98+
steps:
99+
- name: Checkout
100+
uses: actions/checkout@v4
101+
with:
102+
ref: ${{ inputs.version }}
103+
104+
- name: Setup
105+
uses: ./.github/actions/setup
106+
107+
- name: Build
108+
run: just build --release --no-default-features --features ${{ inputs.features }} --target=${{ matrix.target }}
109+
env:
110+
USE_CROSS: ${{ matrix.os == 'ubuntu-latest' }}
111+
112+
- name: Prepare package
113+
run: |
114+
mkdir $DIST_DIR
115+
cp LICENSE $DIST_DIR
116+
cp README*.md $DIST_DIR
117+
echo "Version: ${{ inputs.version }}" > $DIST_DIR/version
118+
echo "Build date: $(date)" >> $DIST_DIR/version
119+
echo "Commit: $(git rev-parse HEAD)" >> $DIST_DIR/version
120+
shell: bash
121+
122+
- name: Publish archive
123+
if: ${{ !contains(matrix.target, 'windows') && !contains(matrix.target, 'darwin') }}
124+
env:
125+
ARCHIVE_FILE: zerotier-edge-${{ matrix.target }}-${{inputs.version}}.tar.gz
126+
run: |
127+
cp target/${{ matrix.target }}/release/zerotier-edge $DIST_DIR
128+
tar -zcvf $ARCHIVE_FILE $DIST_DIR
129+
shasum -a256 $ARCHIVE_FILE > $ARCHIVE_FILE-sha256sum.txt
130+
echo "archive_file=$ARCHIVE_FILE" >> $GITHUB_ENV
131+
132+
- name: Publish zip archive macos
133+
if: ${{ contains(matrix.target, 'darwin') }}
134+
env:
135+
ARCHIVE_FILE: zerotier-edge-${{ matrix.target }}-${{inputs.version}}.zip
136+
run: |
137+
cp target/${{ matrix.target }}/release/zerotier-edge $DIST_DIR
138+
zip -9r $ARCHIVE_FILE $DIST_DIR
139+
shasum -a256 $ARCHIVE_FILE > $ARCHIVE_FILE-sha256sum.txt
140+
echo "archive_file=$ARCHIVE_FILE" >> $GITHUB_ENV
141+
142+
- name: Publish zip archive windows
143+
if: ${{ contains(matrix.target, 'windows') }}
144+
env:
145+
ARCHIVE_FILE: zerotier-edge-${{ matrix.target }}-${{inputs.version}}.zip
146+
run: |
147+
cp target/${{ matrix.target }}/release/zerotier-edge.exe $DIST_DIR
148+
7z a -tzip $ARCHIVE_FILE $DIST_DIR
149+
echo ${{ hashFiles(env.ARCHIVE_FILE) }} > $ARCHIVE_FILE-sha256sum.txt
150+
echo "archive_file=$ARCHIVE_FILE" >> $GITHUB_ENV
151+
shell: bash
152+
153+
- name: Upload artifact
154+
uses: actions/upload-artifact@v4
155+
with:
156+
name: zerotier-edge-${{ matrix.target }}-${{ inputs.version || github.ref_name }}
157+
retention-days: 30
158+
path: ${{ env.archive_file }}
159+
160+
- name: Publish release
161+
uses: softprops/[email protected]
162+
if: ${{ startsWith(inputs.version, 'v') }}
163+
with:
164+
draft: false
165+
prerelease: ${{ inputs.prerelease }}
166+
tag_name: ${{ inputs.version }}
167+
files: |
168+
${{ env.archive_file }}
169+
${{ env.archive_file }}-sha256sum.txt
170+
env:
171+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/nightly.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# .github/workflows/nightly.yml
2+
name: Nightly builds
3+
4+
on:
5+
schedule:
6+
- cron: '30 5,17 * * *'
7+
push:
8+
branches:
9+
- ci*
10+
11+
jobs:
12+
build:
13+
uses: ./.github/workflows/build.yml

.github/workflows/version.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# .github/workflows/version.yml
2+
name: Bump Version
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
bump:
8+
description: 'Bump version'
9+
required: true
10+
type: choice
11+
options: [major, minor, patch, rc, beta, alpha]
12+
default: 'patch'
13+
14+
jobs:
15+
bump:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
version: ${{env.version}}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
24+
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
25+
26+
- name: Setup
27+
uses: ./.github/actions/setup
28+
29+
- name: Bump version ${{ github.event.inputs.bump }}
30+
run: |
31+
just bump ${{ github.event.inputs.bump }}
32+
echo "version=v$(just version)" >> "$GITHUB_ENV"
33+
34+
- name: Commit files
35+
run: |
36+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
37+
git config --local user.name "github-actions[bot]"
38+
git commit -a -m "🔖 Bump version to $version"
39+
git tag -a $version -m ""
40+
41+
- name: Push changes
42+
uses: ad-m/github-push-action@master
43+
with:
44+
github_token: ${{ secrets.GITHUB_TOKEN }}
45+
branch: ${{ github.ref }}
46+
tags: true
47+
48+
build:
49+
needs: [ "bump" ]
50+
uses: ./.github/workflows/build.yml
51+
with:
52+
version: ${{ needs.bump.outputs.version }}
53+
prerelease: ${{ !contains('major, minor, patch', inputs.bump) }}

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ A ZeroTier Controller Web UI for a self-hosted ZeroTier network controller that
2222
```shell
2323
./zerotier-edge
2424
```
25+
2526
Note: `./zerotier-edge --help` will show the help of command.
2627

2728
3. Access Web UI to manage your controller.
@@ -33,12 +34,13 @@ A ZeroTier Controller Web UI for a self-hosted ZeroTier network controller that
3334
4. Configure remote access (optional)
3435

3536
It is recommended to enable https in Nginx and then proxy our service.
36-
37+
3738
```nginx
3839
location /zerotier-edge/ {
3940
proxy_pass http://127.0.0.1:9394/;
4041
}
4142
```
43+
4244
## Building
4345

4446
To build `Zerotier-Edge` from source, ensure that you have [Rust](https://www.rust-lang.org/learn/get-started) installed. Then, follow these steps in your terminal:
@@ -50,11 +52,16 @@ To build `Zerotier-Edge` from source, ensure that you have [Rust](https://www.ru
5052
cd zerotier-edge
5153
```
5254

53-
2. Build:
55+
2. Install dependencies:
56+
57+
```shell
58+
just setup
59+
```
60+
61+
3. Build:
5462

5563
```shell
56-
pnpm install
57-
pnpm run build
64+
just build --release
5865
```
5966

6067
4. Display available options:

justfile

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
cargo := if env_var_or_default('USE_CROSS', 'false') == "true" { "cross" } else { "cargo" }
2+
3+
[private]
4+
alias b := build
5+
6+
[private]
7+
alias t := test
8+
9+
[private]
10+
alias v := version
11+
12+
# Increment manifest version: major, minor, patch, rc, beta, alpha
13+
bump +args: require_set-version
14+
@cargo set-version --bump {{args}}
15+
16+
17+
# Print current version
18+
version:
19+
@cargo pkgid | cut -d@ -f2
20+
21+
setup: require_set-version
22+
pnpm install
23+
24+
# Build
25+
build *args:
26+
npm run build
27+
{{cargo}} build {{args}}
28+
29+
30+
# Run tests
31+
test *args:
32+
{{cargo}} test {{args}}
33+
34+
35+
# Analyze the package and report errors, but don't build object files
36+
check *args:
37+
{{cargo}} check --workspace --tests --benches --examples {{args}}
38+
39+
40+
# Run clippy fix
41+
clippy:
42+
{{cargo}} clippy --fix --all
43+
44+
45+
# format the code
46+
fmt:
47+
{{cargo}} fmt --all
48+
npm run lint-fix
49+
50+
51+
# Check the clippy and format.
52+
cleanliness:
53+
cargo clippy
54+
cargo fmt --all -- --check
55+
56+
57+
# cleanup the workspace
58+
clean:
59+
{{cargo}} clean
60+
61+
[private]
62+
@require_set-version:
63+
cargo set-version --version >/dev/null 2>&1 || cargo install cargo-edit > /dev/null

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "zerotier-edge",
33
"scripts": {
44
"dev": "npm run -w webui -- dev",
5-
"build-ui": "npm run -w webui -- build",
6-
"build": "npm run build-ui && cargo build --release",
7-
"serve": "npm run -w webui -- serve"
5+
"build": "npm run -w webui -- build",
6+
"serve": "npm run -w webui -- serve",
7+
"lint-fix": "npm run -w webui -- lint-fix"
88
},
99
"workspaces": ["webui"]
1010
}

0 commit comments

Comments
 (0)