|
| 1 | +name: C++ Build with Dependencies |
| 2 | + |
| 3 | +#on: [push] # 触发条件,推送和拉取请求时, |
| 4 | +on: |
| 5 | + workflow_dispatch: # 添加这行来启用手动触发 |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + configuration: [Release] |
| 15 | + platform: [x86] |
| 16 | + |
| 17 | + runs-on: windows-latest # 最新的 Windows 环境 |
| 18 | + |
| 19 | + steps: |
| 20 | + # 检出您的主仓库代码 |
| 21 | + - name: Checkout main repository code |
| 22 | + uses: actions/checkout@v3 |
| 23 | + |
| 24 | + # 检出依赖的xengine仓库到指定的xengine目录 |
| 25 | + - name: Checkout dependency repository (xengine) |
| 26 | + uses: actions/checkout@v3 |
| 27 | + with: |
| 28 | + repository: libxengine/xengine |
| 29 | + path: xengine |
| 30 | + |
| 31 | + # 设置依赖库的环境变量 |
| 32 | + - name: Set up Dependency Environment Variables |
| 33 | + run: | |
| 34 | + echo "XENGINE_INCLUDE=${{ github.workspace }}/xengine" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 35 | + echo "XENGINE_LIB32=${{ github.workspace }}/xengine/XEngine_Windows/x86" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 36 | + echo "XENGINE_LIB64=${{ github.workspace }}/xengine/XEngine_Windows/x64" | Out-File -FilePath $env:GITHUB_ENV -Append |
| 37 | + shell: pwsh |
| 38 | + |
| 39 | + # 配置 MSBuild 的路径,准备构建 VC++ 项目 |
| 40 | + - name: Setup MSBuild |
| 41 | + |
| 42 | + #编译 |
| 43 | + - name: Build Solution |
| 44 | + run: msbuild XEngine_Source/XEngine_StorageApp.sln /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} |
| 45 | + |
| 46 | + # 打包 |
| 47 | + - name: Copy Build binaries for x86 |
| 48 | + run: | |
| 49 | + mkdir -p "x86/XEngine_StorageApp" |
| 50 | + cp -r ./XEngine_Release/* x86/XEngine_StorageApp/ |
| 51 | + cp -r ./XEngine_Source/Release/*.dll x86/XEngine_StorageApp/ |
| 52 | + cp -r ./XEngine_Source/Release/*.exe x86/XEngine_StorageApp/ |
| 53 | + cp -r ./XEngine_Source/VSCopy_x86.bat x86/XEngine_StorageApp/ |
| 54 | + cd x86/XEngine_StorageApp && ./VSCopy_x86.bat |
| 55 | + cd .. |
| 56 | + cd .. |
| 57 | + 7z a XEngine_StorageApp-x86-Windows.zip ./x86/XEngine_StorageApp/* |
| 58 | + shell: pwsh |
| 59 | + |
| 60 | + - name: Calculate new tag |
| 61 | + id: newtag |
| 62 | + shell: bash |
| 63 | + run: | |
| 64 | + git fetch --tags |
| 65 | + TAG=$(git tag --sort=-v:refname | head -n 1) |
| 66 | + MAJOR=$(echo $TAG | cut -d '.' -f 1) |
| 67 | + MINOR=$(echo $TAG | cut -d '.' -f 2) |
| 68 | + PATCH=$(echo $TAG | cut -d '.' -f 3) |
| 69 | + BUILD=$(echo $TAG | cut -d '.' -f 4) |
| 70 | + MINOR_BUMP=$((MINOR + 1)) |
| 71 | + NEW_TAG="${MAJOR}.${MINOR_BUMP}.0.${BUILD}" |
| 72 | + echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV |
| 73 | + git config --local user.email "[email protected]" |
| 74 | + git config --local user.name "GitHub Action" |
| 75 | + git tag $NEW_TAG |
| 76 | + git push origin $NEW_TAG |
| 77 | + |
| 78 | + # 创建GitHub Release |
| 79 | + - name: Create Release |
| 80 | + id: create_release |
| 81 | + uses: softprops/action-gh-release@v1 |
| 82 | + with: |
| 83 | + tag_name: ${{ env.NEW_TAG }} |
| 84 | + name: Release ${{ env.NEW_TAG }} |
| 85 | + body: | |
| 86 | + [${{ github.sha }}](https://github.com/libxengine/XEngine_Storage/commit/${{ github.sha }}) |
| 87 | + ${{ github.event.head_commit.message }} |
| 88 | + draft: false |
| 89 | + prerelease: false |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + |
| 93 | + # 上传x86的zip包作为发布的artifacts |
| 94 | + - name: Upload x86 Release Asset |
| 95 | + uses: actions/upload-release-asset@v1 |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + with: |
| 99 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 100 | + asset_path: ./XEngine_StorageApp-x86-Windows.zip |
| 101 | + asset_name: XEngine_StorageApp-x86-Windows.zip |
| 102 | + asset_content_type: application/zip |
0 commit comments