Skip to content

添加自动时间填写 && 时间倒计时添加 && 界面优化 #793 #244

添加自动时间填写 && 时间倒计时添加 && 界面优化 #793

添加自动时间填写 && 时间倒计时添加 && 界面优化 #793 #244

Workflow file for this run

name: Python Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
permissions:
contents: write
discussions: write
env:
WEBDAV_URL: ${{ secrets.WEBDAV_URL }}
WEBDAV_USERNAME: ${{ secrets.WEBDAV_USERNAME }}
WEBDAV_PASSWORD: ${{ secrets.WEBDAV_PASSWORD }}
#https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners
jobs:
build:
name: Build Executables
runs-on: ${{ matrix.config.os.name }}
strategy:
matrix:
config:
- os:
name: ubuntu-22.04
filename: linux_amd64
- os:
name: ubuntu-22.04-arm
filename: linux_arm64
- os:
name: macos-14
filename: macos_arm64
- os:
name: macos-15-intel
filename: macos_intel
- os:
name: windows-latest
filename: windows_amd64
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: "pip"
- name: Upgrade setuptools, wheel, and install requirements
run: |
pip install --upgrade setuptools wheel pyinstaller~=5.13.2 && pip install -r requirements.txt
- name: Build Pyinstaller
shell: bash
run: |
pyinstaller main.spec
- name: Zip the Build-windows
if: matrix.config.os.filename == 'windows_amd64'
run: Compress-Archive -Path ./dist/biliTicKerBuy.exe -DestinationPath tmp.zip
- name: Zip the Build-linux
if: matrix.config.os.filename != 'windows_amd64'
run: |
cd ./dist
zip -r ../tmp.zip biliTickerBuy
- name: Upload binaries to release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
file: tmp.zip
asset_name: ${{ secrets.ReleaseZipName }}_${{ matrix.config.os.filename }}_${{ github.ref_name }}.zip
tag: ${{ github.ref }}
overwrite: true
webdav-upload:
name: Upload to WebDAV
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Extract version
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Download release files
run: |
mkdir -p release-files
# Wait for GitHub Release to complete
sleep 30
ARCHITECTURES=("linux_amd64" "linux_arm64" "macos_arm64" "macos_intel" "windows_amd64")
for arch in "${ARCHITECTURES[@]}"; do
FILE_NAME="${{ secrets.ReleaseZipName }}_${arch}_${{ steps.version.outputs.version }}.zip"
DOWNLOAD_URL="https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.version }}/${FILE_NAME}"
for i in {1..5}; do
if curl -L -f -o "release-files/${FILE_NAME}" "$DOWNLOAD_URL"; then
echo "Downloaded ${FILE_NAME}"
break
else
echo "Download failed, retry $i..."
sleep 10
fi
done
done
- name: Generate version info
run: |
cat > release-files/version-info.json << EOF
{
"version": "${{ steps.version.outputs.version }}",
"release_date": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
"github_release": "https://github.com/${{ github.repository }}/releases/tag/${{ steps.version.outputs.version }}",
"files": {
"linux_amd64": "${{ secrets.ReleaseZipName }}_linux_amd64_${{ steps.version.outputs.version }}.zip",
"linux_arm64": "${{ secrets.ReleaseZipName }}_linux_arm64_${{ steps.version.outputs.version }}.zip",
"macos_arm64": "${{ secrets.ReleaseZipName }}_macos_arm64_${{ steps.version.outputs.version }}.zip",
"macos_intel": "${{ secrets.ReleaseZipName }}_macos_intel_${{ steps.version.outputs.version }}.zip",
"windows_amd64": "${{ secrets.ReleaseZipName }}_windows_amd64_${{ steps.version.outputs.version }}.zip"
}
}
EOF
- name: Upload to WebDAV
run: |
# Install curl
sudo apt-get update && sudo apt-get install -y curl
# Create WebDAV directories
WEBDAV_DIR="releases/${{ steps.version.outputs.version }}"
curl -X MKCOL \
-u "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" \
"$WEBDAV_URL/releases/" || true
curl -X MKCOL \
-u "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" \
"$WEBDAV_URL/$WEBDAV_DIR/" || true
# Upload files to versioned directory
cd release-files
for file in *.zip; do
if [ -f "$file" ]; then
echo "Uploading $file to releases directory..."
curl -T "$file" \
-u "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" \
"$WEBDAV_URL/$WEBDAV_DIR/$file"
fi
done
# Upload version-info.json to releases directory
curl -T "version-info.json" \
-u "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" \
"$WEBDAV_URL/$WEBDAV_DIR/version-info.json"
# Upload latest versions to root directory
echo "Uploading latest versions to root directory..."
for file in *.zip; do
if [ -f "$file" ]; then
echo "Uploading $file to root..."
curl -T "$file" \
-u "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" \
"$WEBDAV_URL/$file"
fi
done
# Upload latest version-info.json to root
curl -T "version-info.json" \
-u "$WEBDAV_USERNAME:$WEBDAV_PASSWORD" \
"$WEBDAV_URL/version-info.json"
echo "WebDAV upload completed"