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
|
||||
@@ -1,183 +0,0 @@
|
||||
name: Release Build
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
RUST_BACKTRACE: 1
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust toolchain
|
||||
uses: dtolnay/rust-action@stable
|
||||
with:
|
||||
targets: x86_64-pc-windows-gnu
|
||||
|
||||
- name: Install MinGW
|
||||
run: sudo apt-get update && sudo apt-get install -y mingw-w64 libssl-dev pkg-config
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ubuntu-cargo-registry-windows-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Build release
|
||||
run: cargo build --release --target x86_64-pc-windows-gnu
|
||||
|
||||
- name: Package Windows
|
||||
run: |
|
||||
mkdir -p release
|
||||
cp target/x86_64-pc-windows-gnu/release/readflow.exe release/
|
||||
cat > release/README.txt << 'EOF'
|
||||
ReadFlow for Windows
|
||||
1. 解压到任意目录
|
||||
2. 双击运行 readflow.exe
|
||||
EOF
|
||||
cd release
|
||||
zip -r ../readflow-windows-x86_64.zip .
|
||||
|
||||
- name: Upload to Release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
artifacts: "readflow-windows-x86_64.zip"
|
||||
tag: ${{ github.ref_name }}
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
allowUpdates: true
|
||||
|
||||
build-linux:
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: x86_64-unknown-linux-gnu
|
||||
profile: minimal
|
||||
|
||||
- name: Install dependencies
|
||||
run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
|
||||
|
||||
- name: Build release
|
||||
run: cargo build --release --target x86_64-unknown-linux-gnu
|
||||
|
||||
- name: Package Linux
|
||||
run: |
|
||||
mkdir -p release
|
||||
cp target/x86_64-unknown-linux-gnu/release/readflow release/
|
||||
chmod +x release/readflow
|
||||
# Create .desktop file
|
||||
cat > release/readflow.desktop << 'EOF'
|
||||
[Desktop Entry]
|
||||
Name=ReadFlow
|
||||
Comment=ReadFlow - 面向开发者和知识工作者的阅读工具
|
||||
Exec=readflow
|
||||
Icon=readflow
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Utility;Reading;
|
||||
EOF
|
||||
cd release
|
||||
tar -czf ../readflow-${{ github.ref_name }}-linux-x86_64.tar.gz readflow readflow.desktop
|
||||
|
||||
- name: Upload to Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
name: Linux x86_64
|
||||
files: readflow-${{ github.ref_name }}-linux-x86_64.tar.gz
|
||||
tag_name: ${{ github.ref_name }}
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
fail_on_unmatched_files: true
|
||||
env:
|
||||
GITHUB_SERVER_URL: http://192.168.120.110:4000
|
||||
GITHUB_REPOSITORY: damai/readflow
|
||||
|
||||
build-macos:
|
||||
name: Build macOS
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Rust toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
target: x86_64-apple-darwin
|
||||
profile: minimal
|
||||
|
||||
- name: Build release
|
||||
run: cargo build --release --target x86_64-apple-darwin
|
||||
|
||||
- name: Package macOS
|
||||
run: |
|
||||
mkdir -p release/ReadFlow.app/Contents/MacOS
|
||||
mkdir -p release/ReadFlow.app/Contents/Resources
|
||||
cp target/release/readflow release/ReadFlow.app/Contents/MacOS/
|
||||
chmod +x release/ReadFlow.app/Contents/MacOS/readflow
|
||||
|
||||
# Create Info.plist
|
||||
cat > release/ReadFlow.app/Contents/Info.plist << 'EOF'
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>readflow</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.readflow.app</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>ReadFlow</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>ReadFlow</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>${{ github.ref_name }}</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${{ github.ref_name }}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOF
|
||||
|
||||
# Copy assets
|
||||
if [ -d "assets" ]; then
|
||||
cp -r assets release/ReadFlow.app/Contents/Resources/
|
||||
fi
|
||||
|
||||
cd release
|
||||
zip -r -X ../readflow-${{ github.ref_name }}-macos-x86_64.zip ReadFlow.app
|
||||
|
||||
- name: Upload to Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
name: macOS x86_64
|
||||
files: readflow-${{ github.ref_name }}-macos-x86_64.zip
|
||||
tag_name: ${{ github.ref_name }}
|
||||
token: ${{ secrets.GITEA_TOKEN }}
|
||||
fail_on_unmatched_files: true
|
||||
env:
|
||||
GITHUB_SERVER_URL: http://192.168.120.110:4000
|
||||
GITHUB_REPOSITORY: damai/readflow
|
||||
Reference in New Issue
Block a user