ci: rollback
This commit is contained in:
+22
-12
@@ -2,10 +2,9 @@
|
|||||||
# It performs CI on every push to main and every pull request, and automatically
|
# It performs CI on every push to main and every pull request, and automatically
|
||||||
# builds and attaches a Linux amd64 release binary when a version tag (v*) is pushed.
|
# builds and attaches a Linux amd64 release binary when a version tag (v*) is pushed.
|
||||||
#
|
#
|
||||||
# Runner: golang-1.25 (Gitea-managed image, alpine + Go 1.25 preinstalled).
|
# Go is installed manually from a Chinese mirror (NJU) instead of using
|
||||||
# No Go installation step needed. GOPROXY is set explicitly to use the
|
# actions/setup-go, because the runner is in a region where the official Go
|
||||||
# China-region mirrors (default alpine GOPROXY is proxy.golang.org, which
|
# download endpoint is slow. GOPROXY is set to goproxy.cn for the same reason.
|
||||||
# is slow from this runner's network).
|
|
||||||
name: CI / Release
|
name: CI / Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -19,13 +18,19 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
name: CI
|
name: CI
|
||||||
runs-on: golang-1.25
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set GOPROXY
|
- name: Install Go (Mirror in China)
|
||||||
run: |
|
run: |
|
||||||
|
if [ ! -d "/usr/local/go" ]; then
|
||||||
|
wget https://mirrors.nju.edu.cn/golang/go1.25.5.linux-amd64.tar.gz
|
||||||
|
sudo tar -C /usr/local -xzf go1.25.5.linux-amd64.tar.gz
|
||||||
|
rm go1.25.5.linux-amd64.tar.gz
|
||||||
|
fi
|
||||||
|
echo "/usr/local/go/bin" >> $GITHUB_PATH
|
||||||
echo "GOPROXY=https://goproxy.cn/,https://goproxy.io,direct" >> $GITHUB_ENV
|
echo "GOPROXY=https://goproxy.cn/,https://goproxy.io,direct" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
@@ -61,13 +66,19 @@ jobs:
|
|||||||
name: Release
|
name: Release
|
||||||
needs: ci
|
needs: ci
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
runs-on: golang-1.25
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: gitea/action-checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set GOPROXY
|
- name: Install Go (Mirror in China)
|
||||||
run: |
|
run: |
|
||||||
|
if [ ! -d "/usr/local/go" ]; then
|
||||||
|
wget https://mirrors.nju.edu.cn/golang/go1.25.5.linux-amd64.tar.gz
|
||||||
|
sudo tar -C /usr/local -xzf go1.25.5.linux-amd64.tar.gz
|
||||||
|
rm go1.25.5.linux-amd64.tar.gz
|
||||||
|
fi
|
||||||
|
echo "/usr/local/go/bin" >> $GITHUB_PATH
|
||||||
echo "GOPROXY=https://goproxy.cn/,https://goproxy.io,direct" >> $GITHUB_ENV
|
echo "GOPROXY=https://goproxy.cn/,https://goproxy.io,direct" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build release binary
|
- name: Build release binary
|
||||||
@@ -84,7 +95,6 @@ jobs:
|
|||||||
|
|
||||||
# 2. 调用 Gitea API 创建一个 Release 并获取其 ID
|
# 2. 调用 Gitea API 创建一个 Release 并获取其 ID
|
||||||
# 注意:${{ github.api_url }} 会自动解析为你本地 Gitea 的 API 地址 (如 http://your-gitea/api/v1)
|
# 注意:${{ github.api_url }} 会自动解析为你本地 Gitea 的 API 地址 (如 http://your-gitea/api/v1)
|
||||||
# alpine busybox grep 不支持 -P (PCRE), 改用两次 grep -o 拆 id
|
|
||||||
RELEASE_ID=$(curl -X POST "${{ github.api_url }}/repos/${{ github.repository }}/releases" \
|
RELEASE_ID=$(curl -X POST "${{ github.api_url }}/repos/${{ github.repository }}/releases" \
|
||||||
-H "accept: application/json" \
|
-H "accept: application/json" \
|
||||||
-H "authorization: token ${GITEA_TOKEN}" \
|
-H "authorization: token ${GITEA_TOKEN}" \
|
||||||
@@ -96,7 +106,7 @@ jobs:
|
|||||||
\"body\": \"Auto generated release assets.\",
|
\"body\": \"Auto generated release assets.\",
|
||||||
\"draft\": false,
|
\"draft\": false,
|
||||||
\"prerelease\": false
|
\"prerelease\": false
|
||||||
}" | grep -o '"id":[0-9]*' | head -n 1 | grep -o '[0-9]*')
|
}" | grep -oP '"id":\s*\K[0-9]+' | head -n 1)
|
||||||
|
|
||||||
echo "Release 创建成功,ID 为: ${RELEASE_ID}"
|
echo "Release 创建成功,ID 为: ${RELEASE_ID}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user