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, Test & Push binaries (Windows) | |
| permissions: | |
| contents: write | |
| on: | |
| pull_request: | |
| push: | |
| paths-ignore: | |
| - '.vscode/*' | |
| - '_build.bat' | |
| - '_build.sh' | |
| - '.clang-format' | |
| - '.clang-tidy' | |
| - '.editorconfig' | |
| - '.gitignore' | |
| - 'License.md' | |
| - 'README.md' | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [windows-latest] | |
| arch: [x64, x86, arm64] | |
| kind: [static, shared] | |
| runtimes: [MT, MD] | |
| mode: [debug, release, releasedbg, minsizerel] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Get current date as package key | |
| id: cache_key | |
| run: echo "key=$(date +'%W')_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.kind }}_${{ matrix.runtimes }}_${{ matrix.mode }}" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: Set vs_runtime string | |
| run: | | |
| if [ "${{ matrix.mode }}" == "debug" ]; then | |
| echo "VS_RUNTIME_STRING=${{ matrix.runtimes }}d" >> $GITHUB_ENV | |
| else | |
| echo "VS_RUNTIME_STRING=${{ matrix.runtimes }}" >> $GITHUB_ENV | |
| fi | |
| shell: bash | |
| - name: Set OUTPUT_FILE variable | |
| run: | | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| echo "OUTPUT_FILE=${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.kind }}_${{ matrix.mode }}_${{ env.VS_RUNTIME_STRING }}.zip" >> $GITHUB_ENV | |
| else | |
| echo "OUTPUT_FILE=${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.kind }}_${{ matrix.mode }}.zip" >> $GITHUB_ENV | |
| fi | |
| shell: bash | |
| # Force xmake to a specific folder (for cache) | |
| - name: Set xmake env | |
| run: echo "XMAKE_GLOBALDIR=${{ runner.workspace }}/xmake-global" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Clone the whole repository to get correct tags and branches | |
| # Install xmake | |
| - name: Setup xmake | |
| uses: xmake-io/github-action-setup-xmake@v1.2.2 | |
| with: | |
| xmake-version: branch@dev | |
| #xmake-version: latest | |
| actions-cache-folder: .xmake-cache-W${{ steps.cache_key.outputs.key }} | |
| # Update xmake repository (in order to have the file that will be cached) | |
| - name: Update xmake repository | |
| run: xmake repo --update -vD | |
| - name: Configure xmake and install dependencies | |
| run: xmake config -vD --plat=windows --arch=${{ matrix.arch }} --mode=${{ matrix.mode }} --kind=${{ matrix.kind }} --vs_runtime=${{ env.VS_RUNTIME_STRING }} --yes --policies=package.precompiled:n | |
| - name: Build all targets | |
| run: xmake build -vD -a | |
| # We can't do --group=TESTS because every test has its own output | |
| - name: Run tests | |
| run: xmake run -vD --group=TESTS | |
| - name: Install | |
| run: xmake install -vDo dest/ --group=EXES | |
| - name: Archive result | |
| uses: ihiroky/archive-action@v1 | |
| with: | |
| root_dir: dest | |
| file_path: ${{ env.OUTPUT_FILE }} | |
| verbose: true | |
| - name: Compute checksum of archive | |
| run: | | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| sha256sum -b "$OUTPUT_FILE" > "$OUTPUT_FILE.sha256" | |
| else | |
| shasum -a 256 -b "$OUTPUT_FILE" > "$OUTPUT_FILE.sha256" | |
| fi | |
| shell: bash | |
| # Release tags (for tags) | |
| - name: Upload binaries to release (Tag) | |
| uses: svenstaro/upload-release-action@v2 | |
| if: ${{ startsWith(github.event.ref, 'refs/tags/') }} | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: ${{ env.OUTPUT_FILE }} | |
| asset_name: ${{ env.OUTPUT_FILE }} | |
| tag: ${{ github.ref }} | |
| overwrite: true | |
| - name: Upload checksum to release (Tag) | |
| uses: svenstaro/upload-release-action@v2 | |
| if: ${{ startsWith(github.event.ref, 'refs/tags/') }} | |
| with: | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| file: ${{ env.OUTPUT_FILE }}.sha256 | |
| asset_name: ${{ env.OUTPUT_FILE }}.sha256 | |
| tag: ${{ github.ref }} | |
| overwrite: true |