Skip to content

Commit 04f52e6

Browse files
authored
Merge pull request #1 from johnlanni/update-hgctl-release
Update hgctl release
2 parents 8043780 + 8c4a98e commit 04f52e6

File tree

789 files changed

+112416
-126879
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

789 files changed

+112416
-126879
lines changed
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Build and Push Wasm Plugin Image
2+
3+
on:
4+
push:
5+
tags:
6+
- "wasm-go-*-v*.*.*" # 匹配 wasm-go-{pluginName}-vX.Y.Z 格式的标签
7+
workflow_dispatch:
8+
inputs:
9+
plugin_name:
10+
description: 'Name of the plugin'
11+
required: true
12+
type: string
13+
version:
14+
description: 'Version of the plugin (optional, without leading v)'
15+
required: false
16+
type: string
17+
18+
jobs:
19+
build-and-push-wasm-plugin-image:
20+
runs-on: ubuntu-latest
21+
environment:
22+
name: image-registry-msg
23+
env:
24+
IMAGE_REGISTRY_SERVICE: ${{ vars.IMAGE_REGISTRY || 'higress-registry.cn-hangzhou.cr.aliyuncs.com' }}
25+
IMAGE_REPOSITORY: ${{ vars.PLUGIN_IMAGE_REPOSITORY || 'plugins' }}
26+
GO_VERSION: 1.19
27+
TINYGO_VERSION: 0.28.1
28+
ORAS_VERSION: 1.0.0
29+
steps:
30+
- name: Set plugin_name and version from inputs or ref_name
31+
id: set_vars
32+
run: |
33+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
34+
plugin_name="${{ github.event.inputs.plugin_name }}"
35+
version="${{ github.event.inputs.version }}"
36+
else
37+
ref_name=${{ github.ref_name }}
38+
plugin_name=${ref_name#*-*-} # 删除插件名前面的字段(wasm-go-)
39+
plugin_name=${plugin_name%-*} # 删除插件名后面的字段(-vX.Y.Z)
40+
version=$(echo "$ref_name" | awk -F'v' '{print $2}')
41+
fi
42+
43+
echo "PLUGIN_NAME=$plugin_name" >> $GITHUB_ENV
44+
echo "VERSION=$version" >> $GITHUB_ENV
45+
46+
- name: Checkout code
47+
uses: actions/checkout@v3
48+
49+
- name: File Check
50+
run: |
51+
workspace=${{ github.workspace }}/plugins/wasm-go/extensions/${PLUGIN_NAME}
52+
push_command="./plugin.tar.gz:application/vnd.oci.image.layer.v1.tar+gzip"
53+
54+
# 查找spec.yaml
55+
if [ -f "${workspace}/spec.yaml" ]; then
56+
echo "spec.yaml exists"
57+
push_command="./spec.yaml:application/vnd.module.wasm.spec.v1+yaml $push_command "
58+
fi
59+
60+
# 查找README.md
61+
if [ -f "${workspace}/README.md" ];then
62+
echo "README.md exists"
63+
push_command="./README.md:application/vnd.module.wasm.doc.v1+markdown $push_command "
64+
fi
65+
66+
# 查找README_{lang}.md
67+
for file in ${workspace}/README_*.md; do
68+
if [ -f "$file" ]; then
69+
file_name=$(basename $file)
70+
echo "$file_name exists"
71+
lang=$(basename $file | sed 's/README_//; s/.md//')
72+
push_command="./$file_name:application/vnd.module.wasm.doc.v1.$lang+markdown $push_command "
73+
fi
74+
done
75+
76+
echo "PUSH_COMMAND=\"$push_command\"" >> $GITHUB_ENV
77+
78+
- name: Run a wasm-go-builder
79+
env:
80+
PLUGIN_NAME: ${{ env.PLUGIN_NAME }}
81+
BUILDER_IMAGE: higress-registry.cn-hangzhou.cr.aliyuncs.com/plugins/wasm-go-builder:go${{ env.GO_VERSION }}-tinygo${{ env.TINYGO_VERSION }}-oras${{ env.ORAS_VERSION }}
82+
run: |
83+
docker run -itd --name builder -v ${{ github.workspace }}:/workspace -e PLUGIN_NAME=${{ env.PLUGIN_NAME }} --rm ${{ env.BUILDER_IMAGE }} /bin/bash
84+
85+
- name: Build Image and Push
86+
run: |
87+
push_command=${{ env.PUSH_COMMAND }}
88+
push_command=${push_command#\"}
89+
push_command=${push_command%\"} # 删除PUSH_COMMAND中的双引号,确保oras push正常解析
90+
91+
target_image="${{ env.IMAGE_REGISTRY_SERVICE }}/${{ env.IMAGE_REPOSITORY}}/${{ env.PLUGIN_NAME }}:${{ env.VERSION }}"
92+
echo "TargetImage=${target_image}"
93+
94+
cd ${{ github.workspace }}/plugins/wasm-go/extensions/${PLUGIN_NAME}
95+
if [ -f ./.buildrc ]; then
96+
echo 'Found .buildrc file, sourcing it...'
97+
. ./.buildrc
98+
else
99+
echo '.buildrc file not found'
100+
fi
101+
echo "EXTRA_TAGS=${EXTRA_TAGS}"
102+
103+
command="
104+
set -e
105+
cd /workspace/plugins/wasm-go/extensions/${PLUGIN_NAME}
106+
go mod tidy
107+
tinygo build -o ./plugin.wasm -scheduler=none -target=wasi -gc=custom -tags=\"custommalloc nottinygc_finalizer ${EXTRA_TAGS}\" .
108+
tar czvf plugin.tar.gz plugin.wasm
109+
echo ${{ secrets.REGISTRY_PASSWORD }} | oras login -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin ${{ env.IMAGE_REGISTRY_SERVICE }}
110+
oras push ${target_image} ${push_command}
111+
"
112+
docker exec builder bash -c "$command"
113+
114+

.github/workflows/build-and-test-plugin.yaml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ on:
1111
paths:
1212
- 'plugins/**'
1313
- 'test/**'
14+
workflow_dispatch: ~
1415

1516
jobs:
1617
lint:
1718
runs-on: ubuntu-latest
1819
steps:
19-
- uses: actions/checkout@v3
20-
- uses: actions/setup-go@v3
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-go@v5
2122
with:
22-
go-version: 1.19
23+
go-version: 1.21.5
2324
# There are too many lint errors in current code bases
2425
# uncomment when we decide what lint should be addressed or ignored.
2526
# - run: make lint
@@ -29,9 +30,9 @@ jobs:
2930
strategy:
3031
matrix:
3132
# TODO(Xunzhuo): Enable C WASM Filters in CI
32-
wasmPluginType: [ GO ]
33+
wasmPluginType: [ GO, RUST ]
3334
steps:
34-
- uses: actions/checkout@v3
35+
- uses: actions/checkout@v4
3536

3637
- name: Free Up GitHub Actions Ubuntu Runner Disk Space 🔧
3738
uses: jlumbroso/free-disk-space@main
@@ -44,12 +45,17 @@ jobs:
4445
swap-storage: true
4546

4647
- name: "Setup Go"
47-
uses: actions/setup-go@v3
48+
uses: actions/setup-go@v5
4849
with:
49-
go-version: 1.19
50+
go-version: 1.21.5
5051

52+
- name: Setup Rust
53+
uses: actions-rs/toolchain@v1
54+
with:
55+
toolchain: stable
56+
if: matrix.wasmPluginType == 'RUST'
5157
- name: Setup Golang Caches
52-
uses: actions/cache@v3
58+
uses: actions/cache@v4
5359
with:
5460
path: |-
5561
~/.cache/go-build
@@ -59,7 +65,7 @@ jobs:
5965
${{ runner.os }}-go
6066
6167
- name: Setup Submodule Caches
62-
uses: actions/cache@v3
68+
uses: actions/cache@v4
6369
with:
6470
path: |-
6571
.git/modules
@@ -80,4 +86,4 @@ jobs:
8086
runs-on: ubuntu-latest
8187
needs: [ higress-wasmplugin-test ]
8288
steps:
83-
- uses: actions/checkout@v3
89+
- uses: actions/checkout@v4

.github/workflows/build-and-test.yaml

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,26 @@ jobs:
1010
lint:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v3
14-
- uses: actions/setup-go@v3
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-go@v5
1515
with:
16-
go-version: 1.19
16+
go-version: 1.21.5
1717
# There are too many lint errors in current code bases
1818
# uncomment when we decide what lint should be addressed or ignored.
1919
# - run: make lint
2020

2121
coverage-test:
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/checkout@v3
24+
- uses: actions/checkout@v4
25+
26+
- name: "Setup Go"
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: 1.21.5
2530

2631
- name: Setup Golang Caches
27-
uses: actions/cache@v3
32+
uses: actions/cache@v4
2833
with:
2934
path: |-
3035
~/.cache/go-build
@@ -33,7 +38,7 @@ jobs:
3338
restore-keys: ${{ runner.os }}-go
3439

3540
- name: Setup Submodule Caches
36-
uses: actions/cache@v3
41+
uses: actions/cache@v4
3742
with:
3843
path: |-
3944
.git/modules
@@ -44,9 +49,11 @@ jobs:
4449

4550
# test
4651
- name: Run Coverage Tests
47-
run: GOPROXY="https://proxy.golang.org,direct" make go.test.coverage
52+
run: |-
53+
go version
54+
GOPROXY="https://proxy.golang.org,direct" make go.test.coverage
4855
- name: Upload coverage to Codecov
49-
uses: codecov/codecov-action@v3
56+
uses: codecov/codecov-action@v4
5057
with:
5158
fail_ci_if_error: false
5259
files: ./coverage.xml
@@ -58,17 +65,17 @@ jobs:
5865
needs: [lint,coverage-test]
5966
steps:
6067
- name: "Checkout ${{ github.ref }}"
61-
uses: actions/checkout@v3
68+
uses: actions/checkout@v4
6269
with:
6370
fetch-depth: 2
6471

6572
- name: "Setup Go"
66-
uses: actions/setup-go@v3
73+
uses: actions/setup-go@v5
6774
with:
68-
go-version: 1.19
75+
go-version: 1.21.5
6976

7077
- name: Setup Golang Caches
71-
uses: actions/cache@v3
78+
uses: actions/cache@v4
7279
with:
7380
path: |-
7481
~/.cache/go-build
@@ -77,7 +84,7 @@ jobs:
7784
restore-keys: ${{ runner.os }}-go
7885

7986
- name: Setup Submodule Caches
80-
uses: actions/cache@v3
87+
uses: actions/cache@v4
8188
with:
8289
path: |-
8390
.git/modules
@@ -90,7 +97,7 @@ jobs:
9097
run: GOPROXY="https://proxy.golang.org,direct" make build
9198

9299
- name: Upload Higress Binary
93-
uses: actions/upload-artifact@v3
100+
uses: actions/upload-artifact@v4
94101
with:
95102
name: higress
96103
path: out/
@@ -105,25 +112,34 @@ jobs:
105112
runs-on: ubuntu-latest
106113
needs: [build]
107114
steps:
108-
- uses: actions/checkout@v3
115+
- uses: actions/checkout@v4
116+
117+
- name: Free Up GitHub Actions Ubuntu Runner Disk Space 🔧
118+
uses: jlumbroso/free-disk-space@main
119+
with:
120+
tool-cache: false
121+
android: true
122+
dotnet: true
123+
haskell: true
124+
large-packages: true
125+
swap-storage: true
109126

110127
- name: "Setup Go"
111-
uses: actions/setup-go@v3
128+
uses: actions/setup-go@v5
112129
with:
113-
go-version: 1.19
130+
go-version: 1.21.5
114131

115132
- name: Setup Golang Caches
116-
uses: actions/cache@v3
133+
uses: actions/cache@v4
117134
with:
118135
path: |-
119136
~/.cache/go-build
120137
~/go/pkg/mod
121138
key: ${{ runner.os }}-go-${{ github.run_id }}
122-
restore-keys: |
123-
${{ runner.os }}-go
139+
restore-keys: ${{ runner.os }}-go
124140

125141
- name: Setup Submodule Caches
126-
uses: actions/cache@v3
142+
uses: actions/cache@v4
127143
with:
128144
path: |-
129145
.git/modules
@@ -139,4 +155,4 @@ jobs:
139155
runs-on: ubuntu-latest
140156
needs: [higress-conformance-test,gateway-conformance-test]
141157
steps:
142-
- uses: actions/checkout@v3
158+
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)