Build Application #7
Workflow file for this run
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 Application | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_override: | |
| description: "构建版本号(例如 v3.0.0),否则使用 Git SHA 的前 7 位" | |
| required: false | |
| default: "" | |
| type: string | |
| jobs: | |
| determine_version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| app_version: ${{ steps.version_info.outputs.app_version }} | |
| steps: | |
| - name: Checkout code (to get SHA) | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine Version | |
| id: version_info | |
| run: | | |
| VERSION_INPUT="${{ github.event.inputs.version_override }}" | |
| SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7) | |
| if [ -n "$VERSION_INPUT" ]; then | |
| APP_VERSION="$VERSION_INPUT" | |
| else | |
| APP_VERSION="$SHORT_SHA" | |
| fi | |
| echo "Determined App Version: $APP_VERSION" | |
| echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT | |
| build_app: | |
| needs: determine_version | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: Linux x86_64 (GNU) | |
| os: ubuntu-latest | |
| cpython_triple: x86_64-unknown-linux-gnu | |
| artifact_suffix: Linux-x64-gnu | |
| - name: Linux aarch64 (GNU) | |
| os: ubuntu-24.04-arm | |
| cpython_triple: aarch64-unknown-linux-gnu | |
| artifact_suffix: Linux-arm64-gnu | |
| - name: macOS x86_64 | |
| os: macos-15-intel | |
| cpython_triple: x86_64-apple-darwin | |
| artifact_suffix: macOS-x64 | |
| - name: macOS aarch64 | |
| os: macos-15 | |
| cpython_triple: aarch64-apple-darwin | |
| artifact_suffix: macOS-arm64 | |
| - name: Windows x86_64 | |
| os: windows-latest | |
| cpython_triple: x86_64-pc-windows-msvc | |
| artifact_suffix: Windows-x64 | |
| - name: Windows aarch64 | |
| os: windows-11-arm | |
| cpython_triple: aarch64-pc-windows-msvc | |
| artifact_suffix: Windows-arm64 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| if: runner.os != 'linux' && runner.os != 'macOS' | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.12" | |
| - name: Set up msys | |
| if: runner.os == 'Windows' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: UCRT64 | |
| - name: Build for Windows | |
| if: runner.os == 'Windows' | |
| env: | |
| CPYTHON_TRIPLE: ${{ matrix.cpython_triple }} | |
| run: | | |
| echo "Building with CPYTHON_TRIPLE=${CPYTHON_TRIPLE}" | |
| chmod +x ./scripts/pack.sh | |
| ./scripts/pack.sh | |
| shell: msys2 {0} | |
| - name: Build for macOS/Linux | |
| if: runner.os == 'macOS' || runner.os == 'Linux' | |
| env: | |
| CPYTHON_TRIPLE: ${{ matrix.cpython_triple }} | |
| run: | | |
| if [[ "$CPYTHON_TRIPLE" == *"musl"* ]]; then | |
| sudo apt-get update | |
| sudo apt-get install -y musl-dev | |
| fi | |
| echo "Building with CPYTHON_TRIPLE=${CPYTHON_TRIPLE}" | |
| chmod +x ./scripts/pack.sh | |
| ./scripts/pack.sh | |
| shell: bash | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: GDUTCourseGrabber-${{ needs.determine_version.outputs.app_version }}-${{ matrix.artifact_suffix }} | |
| path: dist/* |