|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: "Release version (e.g., 0.1.1)" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-linux: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 25 |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Setup xmake |
| 20 | + uses: xmake-io/github-action-setup-xmake@v1 |
| 21 | + with: |
| 22 | + xmake-version: latest |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: | |
| 26 | + sudo apt-get update |
| 27 | + sudo apt-get install -y build-essential |
| 28 | +
|
| 29 | + - name: Install Xlings |
| 30 | + run: curl -fsSL https://d2learn.org/xlings-install.sh | bash |
| 31 | + |
| 32 | + - name: Install GCC 15.1 with Xlings |
| 33 | + run: | |
| 34 | + export PATH=/home/xlings/.xlings_data/bin:$PATH |
| 35 | + xlings install gcc@15.1 -y |
| 36 | +
|
| 37 | + - name: Build with xmake |
| 38 | + run: | |
| 39 | + export PATH=/home/xlings/.xlings_data/bin:$PATH |
| 40 | + xmake f -m release -y -vv |
| 41 | + xmake -y -vv -j$(nproc) |
| 42 | +
|
| 43 | + - name: Run tests |
| 44 | + run: | |
| 45 | + export PATH=/home/xlings/.xlings_data/bin:$PATH |
| 46 | + xmake run templates_test |
| 47 | +
|
| 48 | + - name: Create release package |
| 49 | + run: | |
| 50 | + PKG="mcpplibs-templates-${{ inputs.version }}-linux-x86_64" |
| 51 | + mkdir -p "$PKG" |
| 52 | + cp build/linux/x86_64/release/libmcpplibs-templates.a "$PKG/" |
| 53 | + cp src/templates.cppm README.md LICENSE "$PKG/" |
| 54 | + tar -czf "${PKG}.tar.gz" "$PKG" |
| 55 | +
|
| 56 | + - name: Upload artifact |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: templates-linux-x86_64 |
| 60 | + path: mcpplibs-templates-${{ inputs.version }}-linux-x86_64.tar.gz |
| 61 | + |
| 62 | + build-macos: |
| 63 | + runs-on: macos-14 |
| 64 | + timeout-minutes: 25 |
| 65 | + steps: |
| 66 | + - name: Checkout |
| 67 | + uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + run: brew install xmake llvm@20 |
| 71 | + |
| 72 | + - name: Build with xmake (LLVM 20) |
| 73 | + run: | |
| 74 | + export PATH=/opt/homebrew/opt/llvm@20/bin:$PATH |
| 75 | + xmake f -p macosx -m release --toolchain=llvm --sdk=/opt/homebrew/opt/llvm@20 -y -vv |
| 76 | + xmake -y -vv -j$(sysctl -n hw.ncpu) |
| 77 | +
|
| 78 | + - name: Create release package |
| 79 | + run: | |
| 80 | + PKG="mcpplibs-templates-${{ inputs.version }}-macosx-arm64" |
| 81 | + mkdir -p "$PKG" |
| 82 | + cp build/macosx/arm64/release/libmcpplibs-templates.a "$PKG/" |
| 83 | + cp src/templates.cppm README.md LICENSE "$PKG/" |
| 84 | + tar -czf "${PKG}.tar.gz" "$PKG" |
| 85 | +
|
| 86 | + - name: Upload artifact |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + with: |
| 89 | + name: templates-macosx-arm64 |
| 90 | + path: mcpplibs-templates-${{ inputs.version }}-macosx-arm64.tar.gz |
| 91 | + |
| 92 | + build-windows: |
| 93 | + runs-on: windows-latest |
| 94 | + timeout-minutes: 25 |
| 95 | + steps: |
| 96 | + - name: Checkout |
| 97 | + uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Setup xmake |
| 100 | + uses: xmake-io/github-action-setup-xmake@v1 |
| 101 | + with: |
| 102 | + xmake-version: latest |
| 103 | + |
| 104 | + - name: Build with xmake |
| 105 | + run: | |
| 106 | + xmake f -m release -y -vv |
| 107 | + xmake -y -vv -j$env:NUMBER_OF_PROCESSORS |
| 108 | +
|
| 109 | + - name: Run tests |
| 110 | + run: xmake run templates_test |
| 111 | + |
| 112 | + - name: Create release package |
| 113 | + shell: pwsh |
| 114 | + run: | |
| 115 | + $pkg = "mcpplibs-templates-${{ inputs.version }}-windows-x86_64" |
| 116 | + New-Item -ItemType Directory -Path $pkg -Force | Out-Null |
| 117 | + Copy-Item "build\windows\x64\release\mcpplibs-templates.lib" -Destination "$pkg\" |
| 118 | + Copy-Item "src\templates.cppm" -Destination "$pkg\" |
| 119 | + Copy-Item "README.md" -Destination "$pkg\" |
| 120 | + Copy-Item "LICENSE" -Destination "$pkg\" |
| 121 | + Compress-Archive -Path $pkg -DestinationPath "$pkg.zip" |
| 122 | +
|
| 123 | + - name: Upload artifact |
| 124 | + uses: actions/upload-artifact@v4 |
| 125 | + with: |
| 126 | + name: templates-windows-x86_64 |
| 127 | + path: mcpplibs-templates-${{ inputs.version }}-windows-x86_64.zip |
| 128 | + |
| 129 | + create-release: |
| 130 | + needs: [build-linux, build-macos, build-windows] |
| 131 | + runs-on: ubuntu-latest |
| 132 | + permissions: |
| 133 | + contents: write |
| 134 | + steps: |
| 135 | + - name: Download all artifacts |
| 136 | + uses: actions/download-artifact@v4 |
| 137 | + with: |
| 138 | + path: artifacts |
| 139 | + |
| 140 | + - name: Create Release |
| 141 | + uses: softprops/action-gh-release@v1 |
| 142 | + with: |
| 143 | + tag_name: v${{ inputs.version }} |
| 144 | + name: ${{ inputs.version }} |
| 145 | + draft: false |
| 146 | + prerelease: false |
| 147 | + files: | |
| 148 | + artifacts/templates-linux-x86_64/mcpplibs-templates-${{ inputs.version }}-linux-x86_64.tar.gz |
| 149 | + artifacts/templates-macosx-arm64/mcpplibs-templates-${{ inputs.version }}-macosx-arm64.tar.gz |
| 150 | + artifacts/templates-windows-x86_64/mcpplibs-templates-${{ inputs.version }}-windows-x86_64.zip |
| 151 | + env: |
| 152 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments