From 57dd7aa6c8c2c42dd9e0dc516c2e4b0417af36d1 Mon Sep 17 00:00:00 2001 From: DVKunion Date: Tue, 2 Apr 2024 11:50:19 +0800 Subject: [PATCH] fix: ci --- .github/conf/.goreleaser.yml | 5 +- .github/workflows/build.yml | 9 +- .github/workflows/package.yaml | 85 ------------------ .github/workflows/package.yml | 144 +++++++++++++++++++++++++++++++ .github/workflows/pages.yml | 7 +- .github/workflows/release.yml | 18 ++-- .github/workflows/seamoon.yml | 24 ++++++ Dockerfile | 2 +- web/src/pages/function/index.tsx | 2 +- web/src/pages/service/index.tsx | 7 +- 10 files changed, 193 insertions(+), 110 deletions(-) delete mode 100644 .github/workflows/package.yaml create mode 100644 .github/workflows/package.yml create mode 100644 .github/workflows/seamoon.yml diff --git a/.github/conf/.goreleaser.yml b/.github/conf/.goreleaser.yml index de5b2c1..2297630 100644 --- a/.github/conf/.goreleaser.yml +++ b/.github/conf/.goreleaser.yml @@ -1,7 +1,6 @@ before: hooks: - go mod tidy - - builds: - binary: seamoon env: @@ -15,14 +14,14 @@ builds: - 6 - 7 ldflags: - - -s -w -X github.com/DVKunion/SeaMoon/system/xlog.Version={{.Version}} -X github.com/DVKunion/SeaMoon/system/xlog.Commit={{.Sha}} + - -s -w -X github.com/DVKunion/SeaMoon/system/xlog.Version={{.Version}} -X github.com/DVKunion/SeaMoon/system/xlog.Commit={{.ShortCommit}} checksum: name_template: 'checksums.txt' snapshot: name_template: "{{ .Tag }}-next" upx: - enabled: true - goos: [linux, darwin] + goos: [ linux, darwin ] compress: best changelog: sort: asc diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7233dcc..01859a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,11 +1,6 @@ -name: SeaMoon - +name: seamoon-build on: - push: - tags: - - "*" - pull_request: - branches: [ "main" ] + workflow_call: jobs: build: diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml deleted file mode 100644 index 20aab63..0000000 --- a/.github/workflows/package.yaml +++ /dev/null @@ -1,85 +0,0 @@ -name: Package -on: - push: - tags: - - "*" - -jobs: - package-docker: - name: package-docker - runs-on: ubuntu-20.04 - if: startsWith(github.ref, 'refs/tags/') - strategy: - matrix: - include: - - registry: docker.io - repo: dvkunion/seamoon - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - registry: [ - registry.cn-hangzhou.aliyuncs.com, - registry.cn-shanghai.aliyuncs.com, - registry.cn-qingdao.aliyuncs.com, - registry.cn-beijing.aliyuncs.com, - registry.cn-zhangjiakou.aliyuncs.com, - registry.cn-huhehaote.aliyuncs.com, - registry.cn-shenzhen.aliyuncs.com, - registry.cn-chengdu.aliyuncs.com, - registry.cn-hongkong.aliyuncs.com, - registry.ap-northeast-1.aliyuncs.com, - registry.ap-southeast-1.aliyuncs.com, - registry.ap-southeast-2.aliyuncs.com/seammon/seamoon", - registry.ap-southeast-3.aliyuncs.com, - registry.ap-southeast-5.aliyuncs.com, - registry.ap-south-1.aliyuncs.com, - registry.eu-central-1.aliyuncs.com, - registry.eu-west-1.aliyuncs.com, - registry.us-west-1.aliyuncs.com, - registry.us-east-1.aliyuncs.com, - ] - repo: seamoon/seamoon - username: ${{ secrets.ALIYUN_USERNAME }} - password: ${{ secrets.ALIYUN_PASSWORD }} - - registry: [ - hkccr.ccs.tencentyun.com, - inccr.ccs.tencentyun.com, - sgccr.ccs.tencentyun.com, - thccr.ccs.tencentyun.com, - krccr.ccs.tencentyun.com, - jpccr.ccs.tencentyun.com, - deccr.ccs.tencentyun.com, - useccr.ccs.tencentyun.com, - uswccr.ccs.tencentyun.com, - ] - repo: seamoon/seamoon - username: ${{ secrets.TENCENT_USERNAME }} - password: ${{ secrets.TENCENT_PASSWORD }} - - registry: [ - ccr.ccs.tencentyun.com, - ] - repo: dvkunion/seamoon - username: ${{ secrets.TENCENT_USERNAME }} - password: ${{ secrets.TENCENT_PASSWORD }} - steps: - - uses: actions/checkout@v4 - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 - - uses: docker/login-action@v3 - name: login ${{ matrix.registry }} - with: - registry: ${{ matrix.registry }} - username: ${{ matrix.username }} - password: ${{ matrix.password }} - - uses: docker/build-push-action@v5 - with: - push: true - platforms: | - linux/amd64 - linux/arm64 - linux/386 - tags: | - ${{ matrix.registry }}/${{ matrix.repo }}:latest - ${{ matrix.registry }}/${{ matrix.repo }}:${{github.ref_name}} - build-args: | - VERSION=${{github.ref_name}} - context: ./ \ No newline at end of file diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..e3a8238 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,144 @@ +name: seamoon-package +on: + workflow_call: + secrets: + DOCKERHUB_USERNAME: + required: true + DOCKERHUB_TOKEN: + required: true + ALIYUN_USERNAME: + required: true + ALIYUN_PASSWORD: + required: true + TENCENT_USERNAME: + required: true + TENCENT_PASSWORD: + required: true + +jobs: + package-docker: + name: package-docker + runs-on: ubuntu-20.04 + if: startsWith(github.ref, 'refs/tags/') + strategy: + matrix: + registry: docker.io + repo: dvkunion/seamoon + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + name: login ${{ matrix.registry }} + with: + registry: ${{ matrix.registry }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - uses: docker/build-push-action@v5 + with: + push: true + platforms: | + linux/amd64 + linux/arm64 + linux/386 + tags: | + ${{ matrix.registry }}/${{ matrix.repo }}:latest + ${{ matrix.registry }}/${{ matrix.repo }}:${{github.ref_name}} + build-args: | + VERSION=${{github.ref_name}} + context: ./ + package-aliyun: + name: package-aliyun + runs-on: ubuntu-20.04 + if: startsWith(github.ref, 'refs/tags/') + strategy: + matrix: + registry: [ registry.cn-hangzhou.aliyuncs.com, + registry.cn-shanghai.aliyuncs.com, + registry.cn-qingdao.aliyuncs.com, + registry.cn-beijing.aliyuncs.com, + registry.cn-zhangjiakou.aliyuncs.com, + registry.cn-huhehaote.aliyuncs.com, + registry.cn-shenzhen.aliyuncs.com, + registry.cn-chengdu.aliyuncs.com, + registry.cn-hongkong.aliyuncs.com, + registry.ap-northeast-1.aliyuncs.com, + registry.ap-southeast-1.aliyuncs.com, + registry.ap-southeast-2.aliyuncs.com/seammon/seamoon", + registry.ap-southeast-3.aliyuncs.com, + registry.ap-southeast-5.aliyuncs.com, + registry.ap-south-1.aliyuncs.com, + registry.eu-central-1.aliyuncs.com, + registry.eu-west-1.aliyuncs.com, + registry.us-west-1.aliyuncs.com, + registry.us-east-1.aliyuncs.com, + ] + repo: seamoon/seamoon + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + name: login ${{ matrix.registry }} + with: + registry: ${{ matrix.registry }} + username: ${{ secrets.ALIYUN_USERNAME }} + password: ${{ secrets.ALIYUN_PASSWORD }} + - uses: docker/build-push-action@v5 + with: + push: true + platforms: | + linux/amd64 + linux/arm64 + linux/386 + tags: | + ${{ matrix.registry }}/${{ matrix.repo }}:latest + ${{ matrix.registry }}/${{ matrix.repo }}:${{github.ref_name}} + build-args: | + VERSION=${{github.ref_name}} + context: ./ + package-tencent: + name: package-tecent + runs-on: ubuntu-20.04 + if: startsWith(github.ref, 'refs/tags/') + strategy: + matrix: + registry: [ + hkccr.ccs.tencentyun.com, + inccr.ccs.tencentyun.com, + sgccr.ccs.tencentyun.com, + thccr.ccs.tencentyun.com, + krccr.ccs.tencentyun.com, + jpccr.ccs.tencentyun.com, + deccr.ccs.tencentyun.com, + useccr.ccs.tencentyun.com, + uswccr.ccs.tencentyun.com, + ccr.ccs.tencentyun.com, + ] + repo: seamoon/seamoon + include: + - registry: ccr.ccs.tencentyun.com, + repo: dvkunion/seamoon + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + name: login ${{ matrix.registry }} + with: + registry: ${{ matrix.registry }} + username: ${{ secrets.TENCENT_USERNAME }} + password: ${{ secrets.TENCENT_PASSWORD }} + - uses: docker/build-push-action@v5 + with: + push: true + platforms: | + linux/amd64 + linux/arm64 + linux/386 + tags: | + ${{ matrix.registry }}/${{ matrix.repo }}:latest + ${{ matrix.registry }}/${{ matrix.repo }}:${{github.ref_name}} + build-args: | + VERSION=${{github.ref_name}} + context: ./ \ No newline at end of file diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index a0924f5..b8e1db1 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -1,9 +1,8 @@ # Simple workflow for deploying static content to GitHub Pages -name: Deploy - +name: seamoon-package on: - push: - branches: [ "main", "feat/docs" ] + workflow_call: + jobs: # Single deploy job since we're just deploying deploy: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf61bde..7ac721b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,10 +1,9 @@ -name: goreleaser - +name: seamoon-goreleaser on: - push: - tags: - - "*" - + workflow_call: + secrets: + GO_RELEASER_GITHUB_TOKEN: + required: true jobs: build: name: GoReleaser build @@ -14,6 +13,13 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Build Front + run: | + cd web && npm install | true && npm run build && cp -r dist ../cmd/client/static - name: Set up Go uses: actions/setup-go@v5 with: diff --git a/.github/workflows/seamoon.yml b/.github/workflows/seamoon.yml new file mode 100644 index 0000000..c9e8667 --- /dev/null +++ b/.github/workflows/seamoon.yml @@ -0,0 +1,24 @@ +name: seamoon +on: [ push, pull_request ] +jobs: + build: + uses: ./.github/workflows/build.yml + docs: + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feat/docs' }} + uses: ./.github/workflows/pages.yml + release: + if: startsWith(github.ref, 'refs/tags/') + uses: ./.github/workflows/release.yml + secrets: + GO_RELEASER_GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }} + package: + if: startsWith(github.ref, 'refs/tags/') + uses: ./.github/workflows/package.yml + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + ALIYUN_USERNAME: ${{ secrets.ALIYUN_USERNAME }} + ALIYUN_PASSWORD: ${{ secrets.ALIYUN_PASSWORD }} + TENCENT_USERNAME: ${{ secrets.TENCENT_USERNAME }} + TENCENT_PASSWORD: ${{ secrets.TENCENT_PASSWORD }} + diff --git a/Dockerfile b/Dockerfile index 83bdb7a..b93e1ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # build stage -FROM node:20 as front +FROM node:20.12-alpine3.19 as front COPY .. /src WORKDIR /src/web RUN npm run build diff --git a/web/src/pages/function/index.tsx b/web/src/pages/function/index.tsx index c0446ef..a1f60c2 100644 --- a/web/src/pages/function/index.tsx +++ b/web/src/pages/function/index.tsx @@ -43,7 +43,7 @@ const Tunnel: React.FC = () => { rowKey={"ID"} showActions="hover" rowSelection={{}} - grid={{gutter: 16, xs: 1, sm: 2, md: 2, lg: 2, xl: 3}} + grid={{gutter: 16, xs: 1, sm: 2, md: 2, lg: 2, xl: 3, xxl: 3}} onItem={(record: Serverless.Tunnel) => { return { onClick: () => { diff --git a/web/src/pages/service/index.tsx b/web/src/pages/service/index.tsx index 6cde39d..8608628 100644 --- a/web/src/pages/service/index.tsx +++ b/web/src/pages/service/index.tsx @@ -92,7 +92,7 @@ const Proxy: React.FC = () => { rowKey={"ID"} showActions="hover" rowSelection={{}} - grid={{gutter: 16, xs: 1, sm: 2, md: 2, lg: 2, xl: 3}} + grid={{gutter: 16, xs: 1, sm: 2, md: 2, lg: 2, xl: 3, xxl: 3}} onItem={(record: any) => { return { onClick: () => { @@ -134,7 +134,7 @@ const Proxy: React.FC = () => { content: { render: (_, record) => { const oRecord = oData.get(record.id); - return + return @@ -150,7 +150,8 @@ const Proxy: React.FC = () => { - { return SpeedTransfer({