release: v1.2.2 #22
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
| # Release On Multiple Platform | |
| name: Release | |
| env: | |
| PACKAGE_NAME: xmake-project | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - "v*" | |
| jobs: | |
| build: | |
| strategy: | |
| matrix: | |
| include: | |
| # Windows MD | |
| - os: windows | |
| arch: x86_64 | |
| plat: windows | |
| xmake-arch: x64 | |
| runtime: MD | |
| runs-on: windows-latest | |
| # Windows MDd | |
| - os: windows | |
| arch: x86_64 | |
| plat: windows | |
| xmake-arch: x64 | |
| runtime: MDd | |
| runs-on: windows-latest | |
| # Linux x86_64 | |
| - os: ubuntu | |
| arch: x86_64 | |
| plat: linux | |
| xmake-arch: x86_64 | |
| runtime: "" | |
| runs-on: ubuntu-latest | |
| # Linux arm64 | |
| - os: ubuntu | |
| arch: arm64 | |
| plat: linux | |
| xmake-arch: arm64 | |
| runtime: "" | |
| runs-on: ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runs-on }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup XMake | |
| uses: xmake-io/github-action-setup-xmake@v1 | |
| with: | |
| xmake-version: latest | |
| - name: Configure XMake | |
| working-directory: ${{github.workspace}} | |
| shell: bash | |
| run: | | |
| args="\ | |
| -m release \ | |
| -p ${{ matrix.plat }} \ | |
| -a ${{ matrix.xmake-arch }}" | |
| if [ -n "${{ matrix.runtime }}" ]; then | |
| args="$args --runtimes=${{ matrix.runtime }}" | |
| fi | |
| xmake f $args -y | |
| - name: Build Targets | |
| working-directory: ${{github.workspace}} | |
| run: xmake build | |
| # 使用 xmake 原生 package 机制生成编译完成的二进制包。 | |
| # build/packages/ | |
| # └── x | |
| # └── xmake-project | |
| # └── linux | |
| # └── x86_64 | |
| # └── release | |
| # ├── include/ | |
| # ├── lib/ | |
| # └── bin/ | |
| - name: Generate Packages | |
| working-directory: ${{github.workspace}} | |
| run: xmake package | |
| - name: Generate Archive Name | |
| working-directory: ${{github.workspace}} | |
| shell: bash | |
| run: | | |
| suffix="" | |
| if [ -n "${{ matrix.runtime }}" ]; then | |
| suffix="-${{ matrix.runtime }}" | |
| fi | |
| echo "ARCHIVE_NAME=${{ env.PACKAGE_NAME }}-${{ github.ref_name }}-${{ matrix.plat }}-${{ matrix.xmake-arch }}${suffix}.tar.gz" >> $GITHUB_ENV | |
| # 将 xmake package 生成的二进制包转换为适用于不同平台的独立发布包,去除 xmake 的目录管理层。 | |
| # 构建模式(debug/release)主要影响优化级别和调试信息,并不是二进制兼容性的唯一依据。Windows 下 MSVC Runtime(/MD、/MDd)会影响 CRT 链接方式,与用户工程的 ABI 兼容性直接相关,因此发布包根据 runtime 区分。 | |
| # | |
| # 当前所有包均使用 release 模式构建: | |
| # | |
| # Windows: | |
| # - /MD -> xmake-project-<version>-windows-x64-MD.tar.gz | |
| # - /MDd -> xmake-project-<version>-windows-x64-MDd.tar.gz | |
| # | |
| # Linux: | |
| # Linux 不存在 MSVC Runtime 概念,因此仅根据平台和架构区分: | |
| # - linux-x86_64 | |
| # - linux-arm64 | |
| # | |
| # 原始结构: | |
| # | |
| # xmake-project/ | |
| # └── <plat>/ | |
| # └── <arch>/ | |
| # └── release/ | |
| # ├── include/ | |
| # ├── lib/ | |
| # └── bin/ | |
| # | |
| # 转换后: | |
| # | |
| # xmake-project-v1.1.1-windows-x64-MD.tar.gz | |
| # ├── include/ | |
| # ├── lib/ | |
| # └── bin/ | |
| # | |
| # xmake-project-v1.1.1-windows-x64-MDd.tar.gz | |
| # ├── include/ | |
| # ├── lib/ | |
| # └── bin/ | |
| # | |
| # xmake-project-v1.1.1-linux-x86_64.tar.gz | |
| # ├── include/ | |
| # ├── lib/ | |
| # └── bin/ | |
| - name: Archive Platform Packages | |
| working-directory: ${{github.workspace}} | |
| shell: bash | |
| run: | | |
| group=$(echo "${{ env.PACKAGE_NAME }}" | cut -c1) | |
| tar czf \ | |
| ${{ env.ARCHIVE_NAME }} \ | |
| -C build/packages/${group}/${{ env.PACKAGE_NAME }}/${{ matrix.plat }}/${{ matrix.xmake-arch }}/release . | |
| - name: Upload Platform Packages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.ARCHIVE_NAME }} | |
| path: "*.tar.gz" | |
| include-hidden-files: true | |
| if-no-files-found: error | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download Packages | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: assets | |
| merge-multiple: true | |
| - name: Display Release Assets | |
| run: tree assets -a | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: assets/*.tar.gz | |
| - name: Trigger Update XMake Repo Workflow | |
| uses: benc-uk/workflow-dispatch@v1 | |
| with: | |
| workflow: update-xmake-repo.yml | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| inputs: | | |
| { | |
| "package": "${{ env.PACKAGE_NAME }}" | |
| } |