feat: make things to latest

This commit is contained in:
ckt1031 2023-09-14 11:52:28 +08:00
parent 1e13d9447c
commit 41f5e1351a
13 changed files with 57 additions and 1947 deletions

View File

@ -18,7 +18,7 @@ jobs:
contents: read contents: read
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v3 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Save version info - name: Save version info
run: | run: |
@ -28,20 +28,20 @@ jobs:
run: | run: |
python ./i18n/translate.py --repository_path . --json_file_path ./i18n/en.json python ./i18n/translate.py --repository_path . --json_file_path ./i18n/en.json
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker - name: Extract metadata (tags, labels) for Docker
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with: with:
images: | images: |
ckt1031/one-api-en ckt1031/one-api-en
- name: Build and push Docker images - name: Build and push Docker images
uses: docker/build-push-action@v3 uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with: with:
context: . context: .
push: true push: true

View File

@ -18,20 +18,20 @@ jobs:
contents: read contents: read
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v3 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Save version info - name: Save version info
run: | run: |
git describe --tags > VERSION git describe --tags > VERSION
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry - name: Log in to the Container registry
uses: docker/login-action@v2 uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
@ -39,14 +39,14 @@ jobs:
- name: Extract metadata (tags, labels) for Docker - name: Extract metadata (tags, labels) for Docker
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with: with:
images: | images: |
ckt1031/one-api ckt1031/one-api
ghcr.io/${{ github.repository }} ghcr.io/${{ github.repository }}
- name: Build and push Docker images - name: Build and push Docker images
uses: docker/build-push-action@v3 uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with: with:
context: . context: .
push: true push: true

View File

@ -19,26 +19,26 @@ jobs:
contents: read contents: read
steps: steps:
- name: Check out the repo - name: Check out the repo
uses: actions/checkout@v3 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Save version info - name: Save version info
run: | run: |
git describe --tags > VERSION git describe --tags > VERSION
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Log in to Docker Hub - name: Log in to Docker Hub
uses: docker/login-action@v2 uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to the Container registry - name: Log in to the Container registry
uses: docker/login-action@v2 uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.actor }} username: ${{ github.actor }}
@ -46,14 +46,14 @@ jobs:
- name: Extract metadata (tags, labels) for Docker - name: Extract metadata (tags, labels) for Docker
id: meta id: meta
uses: docker/metadata-action@v4 uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with: with:
images: | images: |
ckt1031/one-api ckt1031/one-api
ghcr.io/${{ github.repository }} ghcr.io/${{ github.repository }}
- name: Build and push Docker images - name: Build and push Docker images
uses: docker/build-push-action@v3 uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64

View File

@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
@ -20,23 +20,19 @@ jobs:
run: | run: |
python ./i18n/translate.py --repository_path . --json_file_path ./i18n/en.json python ./i18n/translate.py --repository_path . --json_file_path ./i18n/en.json
- uses: pnpm/action-setup@v2 - uses: oven-sh/setup-bun@a1800f471a0bc25cddac36bb13e6f436ddf341d7 # v1
with: with:
version: 8 bun-version: latest
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 16
- name: Build Frontend - name: Build Frontend
env: env:
CI: "" CI: ""
run: | run: |
cd web cd web
pnpm install bun install
REACT_APP_VERSION=$(git describe --tags) npm run build REACT_APP_VERSION=$(git describe --tags) bun run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with: with:
go-version: ">=1.18.0" go-version: ">=1.18.0"
- name: Build Backend (amd64) - name: Build Backend (amd64)
@ -51,7 +47,7 @@ jobs:
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o one-api-arm64-en CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o one-api-arm64-en
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
with: with:
files: | files: |

View File

@ -5,35 +5,31 @@ permissions:
on: on:
push: push:
tags: tags:
- '*' - "*"
- '!*-alpha*' - "!*-alpha*"
jobs: jobs:
release: release:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: pnpm/action-setup@v2 - uses: oven-sh/setup-bun@a1800f471a0bc25cddac36bb13e6f436ddf341d7 # v1
with: with:
version: 8 bun-version: latest
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 16
- name: Build Frontend - name: Build Frontend
env: env:
CI: "" CI: ""
run: | run: |
cd web cd web
pnpm install bun install
REACT_APP_VERSION=$(git describe --tags) npm run build REACT_APP_VERSION=$(git describe --tags) bun run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with: with:
go-version: '>=1.18.0' go-version: ">=1.18.0"
- name: Build Backend (amd64) - name: Build Backend (amd64)
run: | run: |
go mod download go mod download
@ -46,7 +42,7 @@ jobs:
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o one-api-arm64 CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)' -extldflags '-static'" -o one-api-arm64
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
with: with:
files: | files: |

View File

@ -12,26 +12,22 @@ jobs:
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: pnpm/action-setup@v2 - uses: oven-sh/setup-bun@a1800f471a0bc25cddac36bb13e6f436ddf341d7 # v1
with: with:
version: 8 bun-version: latest
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 16
- name: Build Frontend - name: Build Frontend
env: env:
CI: "" CI: ""
run: | run: |
cd web cd web
pnpm install bun install
REACT_APP_VERSION=$(git describe --tags) npm run build REACT_APP_VERSION=$(git describe --tags) bun run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with: with:
go-version: ">=1.18.0" go-version: ">=1.18.0"
- name: Build Backend - name: Build Backend
@ -39,7 +35,7 @@ jobs:
go mod download go mod download
go build -ldflags "-X 'one-api/common.Version=$(git describe --tags)'" -o one-api-macos go build -ldflags "-X 'one-api/common.Version=$(git describe --tags)'" -o one-api-macos
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
with: with:
files: one-api-macos files: one-api-macos

View File

@ -15,26 +15,22 @@ jobs:
shell: bash shell: bash
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: pnpm/action-setup@v2 - uses: oven-sh/setup-bun@a1800f471a0bc25cddac36bb13e6f436ddf341d7 # v1
with: with:
version: 8 bun-version: latest
- uses: actions/setup-node@v3
with:
cache: pnpm
node-version: 16
- name: Build Frontend - name: Build Frontend
env: env:
CI: "" CI: ""
run: | run: |
cd web cd web
pnpm install bun install
REACT_APP_VERSION=$(git describe --tags) npm run build REACT_APP_VERSION=$(git describe --tags) bun run build
cd .. cd ..
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with: with:
go-version: ">=1.18.0" go-version: ">=1.18.0"
- name: Build Backend - name: Build Backend
@ -42,7 +38,7 @@ jobs:
go mod download go mod download
go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)'" -o one-api.exe go build -ldflags "-s -w -X 'one-api/common.Version=$(git describe --tags)'" -o one-api.exe
- name: Release - name: Release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v1
if: startsWith(github.ref, 'refs/tags/') if: startsWith(github.ref, 'refs/tags/')
with: with:
files: one-api.exe files: one-api.exe

View File

@ -4,15 +4,14 @@ WORKDIR /app
COPY . . COPY . .
RUN chmod +x ./translate-en.sh && ./translate-en.sh RUN chmod +x ./translate-en.sh && ./translate-en.sh
FROM node:18 as builder FROM oven/bun:latest as builder
WORKDIR /build WORKDIR /build
COPY ./web/package*.json ./ COPY ./web/package*.json ./web/bun.lockb ./web/.npmrc ./
RUN npm i -g pnpm RUN bun i
RUN pnpm i
COPY --from=translator ./app/web . COPY --from=translator ./app/web .
COPY ./VERSION . COPY ./VERSION .
RUN REACT_APP_VERSION=$(cat VERSION) npm run build RUN REACT_APP_VERSION=$(cat VERSION) bun run build
FROM golang AS builder2 FROM golang AS builder2

View File

@ -4,10 +4,10 @@
```shell ```shell
# Runs the app in the development mode # Runs the app in the development mode
npm start bun start
# Builds the app for production to the `build` folder # Builds the app for production to the `build` folder
npm run build bun run build
``` ```
If you want to change the default server, please set `REACT_APP_SERVER` environment variables before build, If you want to change the default server, please set `REACT_APP_SERVER` environment variables before build,

BIN
web/bun.lockb Executable file

Binary file not shown.

View File

@ -6,22 +6,18 @@
"@vitejs/plugin-react-swc": "^3.3.2", "@vitejs/plugin-react-swc": "^3.3.2",
"axios": "^1.5.0", "axios": "^1.5.0",
"history": "^5.3.0", "history": "^5.3.0",
"marked": "^8.0.1", "marked": "^9.0.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-dropzone": "^14.2.3", "react-dropzone": "^14.2.3",
"react-router-dom": "^6.15.0", "react-router-dom": "^6.16.0",
"react-toastify": "^9.1.3", "react-toastify": "^9.1.3",
"react-turnstile": "^1.1.1", "react-turnstile": "^1.1.1",
"semantic-ui-css": "^2.5.0", "semantic-ui-css": "^2.5.0",
"semantic-ui-react": "^2.1.4", "semantic-ui-react": "^2.1.4",
"sharp": "^0.32.5",
"svgo": "^3.0.2",
"vite": "^4.4.9", "vite": "^4.4.9",
"vite-plugin-env-compatible": "^1.1.1", "vite-plugin-env-compatible": "^1.1.1",
"vite-plugin-html": "^3.2.0", "vite-plugin-html": "^3.2.0"
"vite-plugin-image-optimizer": "^1.1.7",
"vite-plugin-sri": "^0.0.2"
}, },
"scripts": { "scripts": {
"start": "vite preview", "start": "vite preview",

File diff suppressed because it is too large Load Diff

View File

@ -2,14 +2,10 @@ import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc' import react from '@vitejs/plugin-react-swc'
import envCompatible from 'vite-plugin-env-compatible' import envCompatible from 'vite-plugin-env-compatible'
import { createHtmlPlugin } from 'vite-plugin-html' import { createHtmlPlugin } from 'vite-plugin-html'
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
//import sri from 'vite-plugin-sri';
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
//sri(),
react(), react(),
ViteImageOptimizer(),
createHtmlPlugin(), createHtmlPlugin(),
envCompatible({ envCompatible({
prefix: "REACT_APP_", prefix: "REACT_APP_",