ci: 简化 Gitea Actions workflow
Some checks failed
Build Release / Build Windows (push) Failing after 6m22s
Some checks failed
Build Release / Build Windows (push) Failing after 6m22s
- 使用更兼容的语法 - 简化编译步骤 - 直接使用 Gitea API 上传 Release 而不是 GitHub Actions
This commit is contained in:
67
.gitea/workflows/build.yml
Normal file
67
.gitea/workflows/build.yml
Normal file
@@ -0,0 +1,67 @@
|
||||
name: Build Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust
|
||||
run: |
|
||||
rustup toolchain install stable --profile minimal --target x86_64-pc-windows-gnu
|
||||
rustup target add x86_64-pc-windows-gnu
|
||||
cargo install --target x86_64-pc-windows-gnu cross 2>&1 || true
|
||||
|
||||
- name: Install MinGW
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y mingw-w64 x86_64-w64-mingw32-posix-runtime
|
||||
|
||||
- name: Build
|
||||
env:
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER: x86_64-w64-mingw32-gcc
|
||||
run: |
|
||||
cargo build --release --target x86_64-pc-windows-gnu
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
mkdir -p dist
|
||||
cp target/x86_64-pc-windows-gnu/release/readflow.exe dist/
|
||||
cd dist
|
||||
zip -r -q readflow-windows-x86_64.zip readflow.exe
|
||||
echo "ReadFlow Windows x86_64" > README.txt
|
||||
echo "Build completed at $(date)" >> README.txt
|
||||
zip -r -q readflow-windows-x86_64.zip README.txt
|
||||
|
||||
- name: Upload to Release
|
||||
run: |
|
||||
TAG="${{ github.ref_name }}"
|
||||
TOKEN="${{ secrets.GITEA_TOKEN }}"
|
||||
|
||||
# Get or create release
|
||||
RELEASE_ID=$(curl -s -X POST "http://192.168.120.110:4000/api/v1/repos/damai/readflow/releases" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\": \"${TAG}\", \"name\": \"ReadFlow ${TAG}\", \"draft\": false, \"prerelease\": false}" \
|
||||
| jq -r '.id')
|
||||
|
||||
if [ "$RELEASE_ID" != "null" ]; then
|
||||
echo "Release exists: ${RELEASE_ID}"
|
||||
else
|
||||
echo "Creating new release"
|
||||
fi
|
||||
|
||||
# Upload asset
|
||||
curl -s -X POST "http://192.168.120.110:4000/api/v1/repos/damai/readflow/releases/${RELEASE_ID}/assets" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/zip" \
|
||||
--data-binary @dist/readflow-windows-x86_64.zip
|
||||
Reference in New Issue
Block a user