This commit is contained in:
+23
-11
@@ -7,26 +7,38 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GOPROXY: https://goproxy.cn,direct
|
||||||
|
GONOSUMCHECK: "*"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
- name: Install Go
|
||||||
with:
|
run: |
|
||||||
go-version-file: backend/go.mod
|
GO_VERSION=$(grep '^go ' backend/go.mod | awk '{print $2}')
|
||||||
cache-dependency-path: backend/go.sum
|
curl -fsSL https://golang.google.cn/dl/go${GO_VERSION}.linux-amd64.tar.gz -o /tmp/go.tar.gz
|
||||||
|
sudo tar -C /usr/local -xzf /tmp/go.tar.gz
|
||||||
|
echo "/usr/local/go/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Go tests
|
- name: Go tests
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
run: go test ./...
|
run: go test ./...
|
||||||
|
|
||||||
- uses: subosito/flutter-action@v2
|
- name: Install Flutter
|
||||||
with:
|
run: |
|
||||||
channel: stable
|
curl -fsSL https://storage.flutter-io.cn/flutter_infra_release/releases/stable/linux/flutter_linux_3.41.6-stable.tar.xz -o /tmp/flutter.tar.xz
|
||||||
cache: true
|
sudo tar -C /opt -xf /tmp/flutter.tar.xz
|
||||||
|
echo "/opt/flutter/bin" >> $GITHUB_PATH
|
||||||
|
env:
|
||||||
|
PUB_HOSTED_URL: https://pub.flutter-io.cn
|
||||||
|
FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn
|
||||||
|
|
||||||
- name: Flutter tests
|
- name: Flutter tests
|
||||||
working-directory: client
|
working-directory: client
|
||||||
run: flutter test
|
run: flutter test
|
||||||
|
env:
|
||||||
|
PUB_HOSTED_URL: https://pub.flutter-io.cn
|
||||||
|
FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn
|
||||||
|
|
||||||
- name: Build backend (linux/amd64)
|
- name: Build backend (linux/amd64)
|
||||||
working-directory: backend
|
working-directory: backend
|
||||||
@@ -35,6 +47,9 @@ jobs:
|
|||||||
- name: Build Flutter Web
|
- name: Build Flutter Web
|
||||||
working-directory: client
|
working-directory: client
|
||||||
run: flutter build web --release --dart-define=BASE_URL=https://jiu.51yanmei.com --dart-define=PUBLIC_URL=https://jiu.51yanmei.com
|
run: flutter build web --release --dart-define=BASE_URL=https://jiu.51yanmei.com --dart-define=PUBLIC_URL=https://jiu.51yanmei.com
|
||||||
|
env:
|
||||||
|
PUB_HOSTED_URL: https://pub.flutter-io.cn
|
||||||
|
FLUTTER_STORAGE_BASE_URL: https://storage.flutter-io.cn
|
||||||
|
|
||||||
- name: Package artifacts
|
- name: Package artifacts
|
||||||
run: |
|
run: |
|
||||||
@@ -46,19 +61,16 @@ jobs:
|
|||||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
FORGEJO_URL: ${{ secrets.FORGEJO_URL }}
|
FORGEJO_URL: ${{ secrets.FORGEJO_URL }}
|
||||||
run: |
|
run: |
|
||||||
# 创建 Release,获取 ID
|
|
||||||
RELEASE_ID=$(curl -sf -X POST "${FORGEJO_URL}/api/v1/repos/${{ gitea.repository }}/releases" \
|
RELEASE_ID=$(curl -sf -X POST "${FORGEJO_URL}/api/v1/repos/${{ gitea.repository }}/releases" \
|
||||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"Release ${VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
-d "{\"tag_name\":\"${VERSION}\",\"name\":\"Release ${VERSION}\",\"draft\":false,\"prerelease\":false}" \
|
||||||
| python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
| python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
||||||
|
|
||||||
# 上传 Go 二进制
|
|
||||||
curl -sf -X POST "${FORGEJO_URL}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets" \
|
curl -sf -X POST "${FORGEJO_URL}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets" \
|
||||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
-F "attachment=@backend/jiu-server"
|
-F "attachment=@backend/jiu-server"
|
||||||
|
|
||||||
# 上传 Flutter Web
|
|
||||||
curl -sf -X POST "${FORGEJO_URL}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets" \
|
curl -sf -X POST "${FORGEJO_URL}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets" \
|
||||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||||
-F "attachment=@web.tar.gz"
|
-F "attachment=@web.tar.gz"
|
||||||
|
|||||||
Reference in New Issue
Block a user