ci: 完全不依赖 GitHub 的 workflow
Some checks failed
Build Windows / Build Windows (push) Failing after 5m35s

- 使用 git clone 代替 actions/checkout
- 所有操作使用基础命令
- 不依赖任何 GitHub Actions

适用场景:
- Gitea Actions 无法访问 GitHub
- 完全离线环境
- 安全要求高的环境
This commit is contained in:
大麦
2026-03-10 17:04:09 +08:00
parent e321271734
commit cd19407f29

View File

@@ -4,17 +4,22 @@ on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build-windows:
build:
name: Build Windows
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Clone repository
run: |
git clone ${GITEA_SERVER_URL}/${GITEA_REPOSITORY}.git .
git checkout ${GITEA_REF_NAME}
env:
GITEA_SERVER_URL: http://192.168.120.110:4000
GITEA_REPOSITORY: damai/readflow
GITEA_REF_NAME: ${{ github.ref_name }}
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
@@ -42,28 +47,25 @@ jobs:
cp target/x86_64-pc-windows-gnu/release/readflow.exe dist/
cd dist
echo "ReadFlow for Windows" > README.txt
echo "Version: ${{ github.ref_name }}" >> README.txt
echo "" >> README.txt
echo "Usage: Double click readflow.exe" >> README.txt
echo "Version: ${GITEA_REF_NAME}" >> README.txt
zip -r readflow-windows-x86_64.zip readflow.exe README.txt
- name: Upload to Release
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_URL: http://192.168.120.110:4000
REPO: damai/readflow
TAG: ${{ github.ref_name }}
run: |
# Get release by tag
RELEASE=$(curl -s "${GITEA_URL}/api/v1/repos/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${GITEA_TOKEN}")
TAG="${GITEA_REF_NAME}"
TOKEN="${GITEA_TOKEN}"
URL="${GITEA_SERVER_URL}"
REPO="${GITEA_REPOSITORY}"
# Get or create release
RELEASE=$(curl -s "${URL}/api/v1/repos/${REPO}/releases/tags/${TAG}" \
-H "Authorization: token ${TOKEN}")
RELEASE_ID=$(echo $RELEASE | jq -r '.id')
if [ "$RELEASE_ID" == "null" ]; then
# Create release
RELEASE_ID=$(curl -s -X POST "${GITEA_URL}/api/v1/repos/${REPO}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
if [ "$RELEASE_ID" == "null" ] || [ -z "$RELEASE_ID" ]; then
RELEASE_ID=$(curl -s -X POST "${URL}/api/v1/repos/${REPO}/releases" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"${TAG}\", \"name\": \"ReadFlow ${TAG}\", \"body\": \"Release ${TAG}\", \"draft\": false}" \
| jq -r '.id')
@@ -72,9 +74,14 @@ jobs:
echo "Release ID: ${RELEASE_ID}"
# Upload asset
curl -s -X POST "${GITEA_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=readflow-windows-x86_64.zip" \
-H "Authorization: token ${GITEA_TOKEN}" \
curl -s -X POST "${URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=readflow-windows-x86_64.zip" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/zip" \
--data-binary @dist/readflow-windows-x86_64.zip
echo "Upload completed!"
echo "Upload completed!"
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_SERVER_URL: http://192.168.120.110:4000
GITEA_REPOSITORY: damai/readflow
GITEA_REF_NAME: ${{ github.ref_name }}