Merge pull request #73 from ITCraftDevelopmentTeam/dependabot/github_… #25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 'Build (Dev)' | |
| on: | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| get-version-number: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| VERSION: ${{ steps.get_version.outputs.VERSION }} | |
| SUB_VERSION: ${{ steps.get_version.outputs.SUB_VERSION }} | |
| steps: | |
| - name: "Checkout" | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: "Setup Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.12 | |
| - name: "Get version number" | |
| id: get_version | |
| run: | | |
| pip install toml | |
| # 获取基础版本号 | |
| BASE_VERSION=$(python -c "import version; print(version.VERSION)") | |
| echo "Base version: $BASE_VERSION" | |
| # 获取最近的标签 | |
| LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| echo "Latest tag: $LATEST_TAG" | |
| # 计算从标签到当前 HEAD 的提交数量 | |
| SUB_VER=$(git rev-list --no-merges --count "$LATEST_TAG"..HEAD) | |
| echo "Sub version: $SUB_VER" | |
| # 组合完整版本号 | |
| FULL_VERSION="${BASE_VERSION}.${SUB_VER}" | |
| echo "Full version: $FULL_VERSION" | |
| echo "VERSION=$FULL_VERSION" >> $GITHUB_OUTPUT | |
| echo "SUB_VERSION=$SUB_VER" >> $GITHUB_OUTPUT | |
| build-windows: | |
| needs: get-version-number | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest] | |
| arch: [x86, x64, arm64] | |
| steps: | |
| - name: "Checkout" | |
| uses: actions/checkout@v6 | |
| - name: "Setup Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.12 | |
| - name: Setup Poetry | |
| uses: snok/install-poetry@v1.4.1 | |
| - name: "Install requirements and build" | |
| shell: bash | |
| run: | | |
| poetry install --all-groups | |
| poetry run nuitka \ | |
| --standalone \ | |
| --onefile \ | |
| --follow-imports \ | |
| --include-package=websockets \ | |
| --include-package=aiosqlite \ | |
| --include-package=sqlalchemy \ | |
| --include-package=fastapi \ | |
| --include-package=uvicorn \ | |
| --output-dir=build \ | |
| --lto=yes \ | |
| --windows-icon-from-ico=icon.ico \ | |
| --enable-console \ | |
| --assume-yes-for-downloads \ | |
| main.py | |
| - name: "Rename application" | |
| shell: pwsh | |
| run: | | |
| if (Test-Path "build\main.exe") { | |
| Move-Item -Path "build\main.exe" -Destination "build\onedisc-${{ matrix.arch }}.exe" | |
| } else { | |
| Write-Host "Error: main.exe not found in build directory" | |
| Get-ChildItem -Path "build" -Recurse | |
| exit 1 | |
| } | |
| - name: "Upload build" | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: OneDisc-${{ needs.get-version-number.outputs.VERSION }}-windows-${{ matrix.arch }} | |
| path: build/onedisc-${{ matrix.arch }}.exe | |
| build-linux-macos: | |
| needs: get-version-number | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-22.04 | |
| platform: linux | |
| - os: macos-latest | |
| platform: macos | |
| arch: [x64, arm64] | |
| steps: | |
| - name: "Checkout" | |
| uses: actions/checkout@v6 | |
| - name: "Setup Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.12 | |
| - name: Setup Poetry | |
| uses: snok/install-poetry@v1.4.1 | |
| - name: "Install system dependencies (Linux)" | |
| if: matrix.platform == 'linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libsqlite3-dev | |
| - name: "Install requirements and build" | |
| run: | | |
| poetry install --all-groups | |
| poetry run nuitka --standalone \ | |
| --onefile \ | |
| --follow-imports \ | |
| --include-package=websockets \ | |
| --include-package=aiosqlite \ | |
| --include-package=sqlalchemy \ | |
| --include-package=fastapi \ | |
| --include-package=uvicorn \ | |
| --output-dir=build \ | |
| --lto=yes \ | |
| --assume-yes-for-downloads \ | |
| main.py | |
| - name: "Rename application" | |
| run: | | |
| if [ -f "build/main.bin" ]; then | |
| mv build/main.bin build/onedisc-${{ matrix.platform }}-${{ matrix.arch }} | |
| else | |
| echo "Error: main.bin not found in build directory" | |
| ls -la build/ | |
| exit 1 | |
| fi | |
| - name: "Upload build" | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: OneDisc-${{ needs.get-version-number.outputs.VERSION }}-${{ matrix.platform }}-${{ matrix.arch }} | |
| path: build/onedisc-${{ matrix.platform }}-${{ matrix.arch }} | |
| deploy: | |
| needs: get-version-number | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "Checkout" | |
| uses: actions/checkout@v6 | |
| - name: "Set up Node.js" | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '21' | |
| registry-url: 'https://registry.npmjs.org/' | |
| - name: Install requirements | |
| run: | | |
| npm install | |
| - name: Build Documents | |
| run: | | |
| npm run docs:build | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs/.vitepress/dist/ |