|
| 1 | +name: Manual .NET Build (Artifacts) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + target_rids: |
| 7 | + description: 'Target RIDs (comma separated). E.g: linux-x64, win-x64, osx-arm64' |
| 8 | + required: true |
| 9 | + default: 'linux-x64, win-x64' |
| 10 | + type: string |
| 11 | + |
| 12 | + build_configs: |
| 13 | + description: 'Configurations (comma separated). E.g: Release, Debug' |
| 14 | + required: true |
| 15 | + default: 'Release' |
| 16 | + type: string |
| 17 | + |
| 18 | + is_self_contained: |
| 19 | + description: 'Self Contained? (Includes .NET Runtime, larger size but no install required)' |
| 20 | + required: true |
| 21 | + type: boolean |
| 22 | + default: true |
| 23 | + |
| 24 | + is_single_file: |
| 25 | + description: 'Publish as Single File? (Cleaner output)' |
| 26 | + required: true |
| 27 | + type: boolean |
| 28 | + default: false |
| 29 | + |
| 30 | +env: |
| 31 | + PROJECT_PATH: ./OpenBioCardServer/OpenBioCardServer.csproj |
| 32 | + DOTNET_VERSION: '10.0.x' |
| 33 | + |
| 34 | +jobs: |
| 35 | + build-matrix: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + permissions: |
| 38 | + contents: read |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout Release Branch |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + ref: release |
| 45 | + |
| 46 | + - name: Setup .NET |
| 47 | + uses: actions/setup-dotnet@v4 |
| 48 | + with: |
| 49 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 50 | + |
| 51 | + - name: Restore Dependencies |
| 52 | + run: dotnet restore ${{ env.PROJECT_PATH }} |
| 53 | + |
| 54 | + # 核心逻辑:解析逗号分隔的输入,循环构建 |
| 55 | + - name: Build and Publish Loop |
| 56 | + id: build_step |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + IFS=',' read -ra RIDS <<< "${{ inputs.target_rids }}" |
| 60 | + IFS=',' read -ra CONFIGS <<< "${{ inputs.build_configs }}" |
| 61 | + |
| 62 | + SELF_CONTAINED="" |
| 63 | + if [ "${{ inputs.is_self_contained }}" == "true" ]; then |
| 64 | + SELF_CONTAINED="--self-contained true" |
| 65 | + else |
| 66 | + SELF_CONTAINED="--self-contained false" |
| 67 | + fi |
| 68 | +
|
| 69 | + SINGLE_FILE="" |
| 70 | + if [ "${{ inputs.is_single_file }}" == "true" ]; then |
| 71 | + SINGLE_FILE="-p:PublishSingleFile=true" |
| 72 | + fi |
| 73 | +
|
| 74 | + mkdir -p ./artifacts |
| 75 | +
|
| 76 | + for rid in "${RIDS[@]}"; do |
| 77 | + rid=$(echo $rid | xargs) |
| 78 | + |
| 79 | + for config in "${CONFIGS[@]}"; do |
| 80 | + config=$(echo $config | xargs) |
| 81 | + |
| 82 | + echo "---------------------------------------------------" |
| 83 | + echo "🚀 Building for: RID=[$rid] | Config=[$config]" |
| 84 | + echo "---------------------------------------------------" |
| 85 | + |
| 86 | + OUT_NAME="OpenBioCardServer-${rid}-${config}" |
| 87 | + OUT_DIR="./build_temp/${OUT_NAME}" |
| 88 | + |
| 89 | + dotnet publish ${{ env.PROJECT_PATH }} \ |
| 90 | + -c $config \ |
| 91 | + -r $rid \ |
| 92 | + $SELF_CONTAINED \ |
| 93 | + $SINGLE_FILE \ |
| 94 | + -o $OUT_DIR |
| 95 | + |
| 96 | + cd ./build_temp |
| 97 | + zip -r "../artifacts/${OUT_NAME}.zip" "${OUT_NAME}" |
| 98 | + cd .. |
| 99 | + |
| 100 | + echo "✅ Created: ./artifacts/${OUT_NAME}.zip" |
| 101 | + done |
| 102 | + done |
| 103 | +
|
| 104 | + - name: Upload Artifacts |
| 105 | + uses: actions/upload-artifact@v4 |
| 106 | + with: |
| 107 | + name: OpenBioCard-Builds |
| 108 | + path: ./artifacts/*.zip |
| 109 | + retention-days: 5 |
0 commit comments