Skip to content

Commit 8cb6051

Browse files
authored
Merge pull request #1 from ForNetCode/cicd
[CICD] fix github actions
2 parents 22e5069 + 3c2fd85 commit 8cb6051

File tree

10 files changed

+98
-80
lines changed

10 files changed

+98
-80
lines changed

.github/workflows/client_build.yml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
version:
66
required: true
77
description: "version to release"
8-
branch:
9-
default: main
10-
description: "git branch"
118
env:
129
REGISTRY: ghcr.io
1310
jobs:
@@ -17,7 +14,6 @@ jobs:
1714
- uses: actions/checkout@v3
1815
with:
1916
submodules: true
20-
ref: ${{ github.event.inputs.branch }}
2117
-
2218
name: Set up Docker Buildx
2319
uses: docker/setup-buildx-action@v2
@@ -33,49 +29,57 @@ jobs:
3329
uses: docker/build-push-action@v2
3430
with:
3531
context: .
36-
platforms: linux/amd64,linux/arm64
32+
#platforms: linux/amd64,linux/arm64
3733
push: true
38-
file: command/client/client.Dockerfile
34+
file: command/docker/client/client.Dockerfile
3935
cache-from: type=gha
4036
cache-to: type=gha,mode=max
41-
tags: fornetcode/fornet:${{github.event.inputs.version}}
37+
tags: ${{ env.REGISTRY }}/fornetcode/fornet:${{github.event.inputs.version}}
4238
commandLine:
4339
strategy:
40+
max-parallel: 1
41+
fail-fast: true
4442
matrix:
4543
settings:
4644
- host: ubuntu-latest
4745
target: x86_64-unknown-linux-gnu
4846
build: make release-linux
49-
- host: macos-latest
50-
target: aarch64-apple-darwin
51-
build: make release-mac-aarch_64
5247
- host: macos-latest
5348
target: x86_64-apple-darwin
5449
build: make release-mac-x86_64
55-
runs-on: ${{ matrix.settings.os }}
50+
# - host: macos-latest # This needs aarch64 OpenSSL, will wait github action support MacOS M1(https://github.com/github/roadmap/issues/528), then run this.
51+
# target: aarch64-apple-darwin
52+
# build: make release-mac-aarch64
53+
runs-on: ${{ matrix.settings.host }}
5654
steps:
5755
- uses: actions/checkout@v3
5856
with:
5957
submodules: true
6058
- name: Install Rust
61-
uses: actions-rs/toolchain@v2
59+
uses: actions-rs/toolchain@v1
6260
with:
6361
toolchain: stable
64-
- name: Cache cargo registry
65-
uses: actions/cache@v2
66-
with:
67-
path: ~/.cargo/registry
68-
key: ${{ matrix.settings.os }}-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }}
69-
- name: Cache cargo index
70-
uses: actions/cache@v2
62+
target: ${{ matrix.settings.target }}
63+
profile: minimal
64+
- name: Set up cargo cache
65+
uses: actions/cache@v3
66+
continue-on-error: false
7167
with:
72-
path: ~/.cargo/git
73-
key: ${{ matrix.settings.os }}-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
68+
path: |
69+
~/.cargo/bin/
70+
~/.cargo/registry/index/
71+
~/.cargo/registry/cache/
72+
~/.cargo/git/db/
73+
client/target/
74+
key: ${{ matrix.settings.host }}-${{ matrix.settings.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
75+
restore-keys: ${{ matrix.settings.host }}-cargo-${{ matrix.settings.target }}
76+
# - name: Setup tmate session
77+
# uses: mxschmitt/action-tmate@v3
7478
- name: Build
7579
run: ${{ matrix.settings.build }}
7680

7781
- name: Upload artifact
7882
uses: actions/upload-artifact@v2
7983
with:
80-
path: /release/*
84+
path: release/*
8185
if-no-files-found: error

.github/workflows/server_build.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ on:
55
version:
66
required: true
77
description: "version to release"
8-
branch:
9-
default: main
10-
description: "git branch"
118

129
env:
1310
REGISTRY: ghcr.io
@@ -16,17 +13,16 @@ jobs:
1613
runs-on: ubuntu-latest
1714
steps:
1815
- uses: actions/checkout@v3
19-
with:
20-
ref: ${{ github.event.inputs.branch }}
2116
- uses: coursier/cache-action@v6
2217
- uses: coursier/setup-action@v1
2318
with:
2419
jvm: temurin:1.17
2520
- name: Setup node
2621
uses: actions/setup-node@v3
2722
with:
28-
node-version: lts
29-
cache: 'npm'
23+
node-version: 18
24+
cache: 'npm'
25+
cache-dependency-path: 'admin-web/package-lock.json'
3026
- name: Set up Docker Buildx
3127
uses: docker/setup-buildx-action@v2
3228
-
@@ -42,9 +38,9 @@ jobs:
4238
name: build and push docker image
4339
uses: docker/build-push-action@v2
4440
with:
45-
context: command/backend
41+
context: command/docker/backend
4642
#platforms: linux/amd64,linux/arm64
4743
push: true
4844
cache-from: type=gha
4945
cache-to: type=gha,mode=max
50-
tags: fornetcode/fornet-backend:${{github.event.inputs.version}}
46+
tags: ${{ env.REGISTRY }}/fornetcode/fornet-backend:${{github.event.inputs.version}}

Makefile

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
11
# This is for .github/workflows.
2-
.PHONY: release-mac-x86_64, release-mac-aarch_64, release-linux, release-backend
2+
.PHONY: release-mac-x86_64, release-mac-aarch64, release-linux, release-backend
33

4-
5-
release-mac-x86_64:
6-
mkdir /protoc && cd /protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-osx.x86_64.zip && unzip protoc-21.9-osx.x86_64.zip && cp bin/* /usr/bin/
7-
brew install cmake
8-
mkdir -p release
9-
cd client
10-
cargo build --release
11-
strip target/release/fornet
12-
otool -L target/release/fornet
13-
strip target/release/fornet-cli
14-
otool -L target/release/fornet-cli
15-
tar -C ./target/release/ -czvf ../release/fornet-mac-x86_64.tar.gz ./fornet ./fornet-cli
16-
ls -lisah ../release/fornet-mac-x86_64.tar.gz
4+
#base_dir := $(shell pwd)
175

18-
release-mac-aarch_64:
19-
mkdir /protoc && cd /protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-osx.aarch_64.zip && unzip protoc-21.9-osx.aarch_64.zip && cp bin/* /usr/bin/
20-
brew install cmake
21-
mkdir -p release
22-
cd client
23-
cargo build --release
24-
strip target/release/fornet
25-
otool -L target/release/fornet
26-
strip target/release/fornet-cli
27-
otool -L target/release/fornet-cli
28-
tar -C ./target/release/ -czvf ../release/fornet-mac-aarch_64.tar.gz ./fornet ./fornet-cli
29-
ls -lisah ../release/fornet-mac-aarch_64.tar.gz
6+
#export PROTOC := $(shell pwd)/protoc/bin
307

31-
release-linux:
32-
mkdir /protoc && cd /protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-$(uname -m).zip && unzip protoc-21.9-linux-$(uname -m).zip && cp bin/* /usr/bin/
33-
apt-get install -y build-essential libssl-dev cmake
8+
release-mac-x86_64:
9+
mkdir protoc && cd protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-osx-x86_64.zip && unzip protoc-21.9-osx-x86_64.zip && sudo cp bin/protoc /usr/local/bin
10+
cp -r protoc/include/* protobuf/
3411
mkdir -p release
35-
cd client
36-
cargo build --release
37-
strip target/release/fornet
38-
strip target/release/fornet-cli
39-
tar -C ./target/release/ -czvf ../release/fornet-linux-$(uname -m).tar.gz ./fornet ./fornet-cli
12+
cd client && cargo build --release --target=x86_64-apple-darwin
13+
strip client/target/x86_64-apple-darwin/release/fornet
14+
otool -L client/target/x86_64-apple-darwin/release/fornet
15+
strip client/target/x86_64-apple-darwin/release/fornet-cli
16+
otool -L client/target/x86_64-apple-darwin/release/fornet-cli
17+
tar -C client/target/x86_64-apple-darwin/release/ -czvf release/fornet-mac-x86_64.tar.gz ./fornet ./fornet-cli
18+
19+
release-mac-aarch64:
20+
mkdir protoc && cd protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-osx-aarch_64.zip && unzip protoc-21.9-osx-aarch_64.zip && sudo cp bin/protoc /usr/local/bin
21+
cp -r protoc/include/* protobuf/
22+
mkdir -p release
23+
cd client && cargo build --release --target=aarch64-apple-darwin
24+
strip client/target/aarch64-apple-darwin/release/fornet
25+
otool -L client/target/aarch64-apple-darwin/release/fornet
26+
strip client/target/aarch64-apple-darwin/release/fornet-cli
27+
otool -L client/target/aarch64-apple-darwin/release/fornet-cli
28+
tar -C client/target/aarch64-apple-darwin/release/ -czvf release/fornet-mac-aarch64.tar.gz ./fornet ./fornet-cli
29+
30+
release-linux:
31+
mkdir protoc && cd protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-x86_64.zip && unzip protoc-21.9-linux-x86_64.zip && sudo cp bin/protoc /usr/bin
32+
cp -r protoc/include/* protobuf/
33+
sudo apt-get install -y build-essential libssl-dev cmake
34+
mkdir release
35+
cd client && cargo build --release --target=x86_64-unknown-linux-gnu
36+
strip client/target/x86_64-unknown-linux-gnu/release/fornet
37+
strip client/target/x86_64-unknown-linux-gnu/release/fornet-cli
38+
tar -C client/target/x86_64-unknown-linux-gnu/release/ -czvf release/fornet-linux-x86_64.tar.gz ./fornet ./fornet-cli
4039

4140
release-backend:
42-
cd admin-web && npm ci && npm run build:prod
43-
cp -r /build/ ../command/docker/backend/web
44-
cd ../backend && sbt universal:packageBin
45-
cp ./target/universal/app-*.zip ../command/docker/backend/app.zip && cd ../command/docker/backend && unzip app.zip && rm app.zip && mv app-* app
41+
cd admin-web && npm ci && npm run build:prod && cd ../
42+
cp -r admin-web/build/ command/docker/backend/web
43+
cd backend && sbt universal:packageBin && cd ../
44+
cp backend/target/universal/app-*.zip command/docker/backend/app.zip && cd command/docker/backend && unzip app.zip && rm app.zip && mv app-* app

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ForNet is another Layer3 Virutal Private Network software, built on top of [Bori
77
currently, it's in `beta` stage, supports macOS and Linux, Windows is in blocked for tun driver sign.
88

99
## Document
10-
To check out docs, visit [git page](https://fornetcode.github.io). There's also a [Roadmap](https://fornetcode.github.io/plan) to show you where the project go.
10+
To check out docs, visit [git page](https://fornetcode.github.io/documentation). There's also a [Roadmap](https://fornetcode.github.io/documentation/plan) to show you where the project go.
1111

1212

1313
## License

admin-web/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
BROWSER=none
22
REACT_APP_BASE_API="/api"
3+
34
# FAST_REFRESH=false # trigger this to force refresh less config. 来回改它可强制刷新样式配置

admin-web/src/view/node/CreateNodePage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function CreateNodePage() {
1111
let {networkId} = useParams<{ networkId: string }>()
1212
const [network, setNetwork] = useState<Network>()
1313
const [form] = Form.useForm<CreateNode>()
14-
const nodeType = Form.useWatch('nodeType', form);
14+
Form.useWatch('nodeType', form);
1515
const navi = useNavigate()
1616
const intl = useIntl()
1717
useEffect(() => {

admin-web/src/view/node/NodeDetailPage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {useParams} from "react-router-dom";
2-
import {Button, Form, Input, InputNumber, message, Row, Col, Space} from "antd";
2+
import {Button, Form, Input, InputNumber, message, Row, Col} from "antd";
33
import {useIntl} from "react-intl";
44
import {getNode, NodeType, Node, updateNode} from "../../api/nodeAPI";
55
import {enumToDesc} from "../../local/intl";
@@ -78,6 +78,7 @@ export default function NodeDetailPage() {
7878
})
7979

8080
}
81+
// eslint-disable-next-line
8182
}, [networkId, nodeId])
8283
if (!network) {
8384
return <></>

command/docker/client/client.Dockerfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,26 @@ ARG BASE_IMAGE=rust:1.65
99
#ARG RUNTIME_IMAGE=alpine
1010
ARG RUNTIME_IMAGE=rust:1.65
1111

12-
FROM ${BASE_IMAGE} AS builder
12+
FROM --platform=$BUILDPLATFORM ${BASE_IMAGE} AS builder
13+
14+
RUN apt update && apt install -y cmake bash
1315

1416

15-
RUN mkdir /protoc && cd /protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-$(uname -m).zip && unzip protoc-21.9-linux-$(uname -m).zip && cp bin/* /usr/bin/
1617
#RUN apt update && apt upgrade -y && apt install -y protobuf-compiler libprotobuf-dev
17-
RUN apt update && apt install -y cmake
18+
1819
# Add our source code.
1920
ADD protobuf /source/protobuf
20-
RUN cp -r /protoc/include/* /source/protobuf/
2121
ADD third /source/third
2222
ADD client /source/client
23-
# This is for windows, But must be in for cargo.
2423
ADD win-tun-driver /source/win-tun-driver
25-
24+
ADD command/docker/client/script.sh /script.sh
25+
RUN chmod +x /script.sh && /script.sh
2626
#RUN ls -al && cd protobuf && ls -al && cd ../
27+
2728
RUN --mount=type=cache,target=/usr/local/cargo/registry \
28-
cd /source/client && cargo build --release
29+
cd /source/client && cargo build --release
2930

30-
FROM ${RUNTIME_IMAGE}
31+
FROM --platform=$BUILDPLATFORM ${RUNTIME_IMAGE}
3132

3233
ENV FORNET_CONFIG=/config
3334

command/docker/client/client.Dockerfile.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/app
77
/backend
88
/command
9+
!/command/docker/client
910
/docs
1011
/java_backend
1112
/node_modules

command/docker/client/script.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
# this runs in Docker to build
4+
5+
mkdir /protoc && cd /protoc
6+
7+
architecture=$(uname -m)
8+
if [ $architecture == aarch64 ];
9+
then
10+
architecture='aarch_64'
11+
fi
12+
13+
wget https://github.com/protocolbuffers/protobuf/releases/download/v21.9/protoc-21.9-linux-$architecture.zip && unzip protoc-21.9-linux-$architecture.zip && cp bin/* /usr/bin/
14+
15+
cp -r /protoc/include/* /source/protobuf/

0 commit comments

Comments
 (0)