diff --git a/.github/actions/setup-ninja/action.yml b/.github/actions/setup-ninja/action.yml new file mode 100644 index 00000000..a1d3ad98 --- /dev/null +++ b/.github/actions/setup-ninja/action.yml @@ -0,0 +1,62 @@ +name: 'Setup ninja' +description: 'Download ninja and add it to the PATH environment variable' +inputs: + version: + description: 'Ninja version' + default: '1.12.1' +runs: + using: 'composite' + steps: + - name: 'Calculate variables' + id: calc + shell: sh + run: | + case "${{ runner.os }}-${{ runner.arch }}" in + "Linux-X86" | "Linux-X64") + archive="ninja-linux.zip" + ;; + "Linux-ARM64") + archive="ninja-linux-aarch64.zip" + ;; + "macOS-X86" | "macOS-X64" | "macOS-ARM64") + archive="ninja-mac.zip" + ;; + "Windows-X86" | "Windows-X64") + archive="ninja-win.zip" + ;; + "Windows-ARM64") + archive="ninja-winarm64.zip" + ;; + *) + echo "Unsupported ${{ runner.os }}-${{ runner.arch }}" + exit 1; + ;; + esac + echo "archive=${archive}" >> ${GITHUB_OUTPUT} + echo "cache-key=${archive}-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT} + - name: 'Restore cached ${{ steps.calc.outputs.archive }}' + id: cache-restore + uses: actions/cache/restore@v4 + with: + path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}' + key: ${{ steps.calc.outputs.cache-key }} + - name: 'Download ninja ${{ inputs.version }} for ${{ runner.os }} (${{ runner.arch }})' + if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }} + shell: pwsh + run: | + Invoke-WebRequest "https://github.com/ninja-build/ninja/releases/download/v${{ inputs.version }}/${{ steps.calc.outputs.archive }}" -OutFile "${{ runner.temp }}/${{ steps.calc.outputs.archive }}" + - name: 'Cache ${{ steps.calc.outputs.archive }}' + if: ${{ !steps.cache-restore.outputs.cache-hit || steps.cache-restore.outputs.cache-hit == 'false' }} + uses: actions/cache/save@v4 + with: + path: '${{ runner.temp }}/${{ steps.calc.outputs.archive }}' + key: ${{ steps.calc.outputs.cache-key }} + - name: 'Extract ninja' + shell: pwsh + run: | + 7z "-o${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" x "${{ runner.temp }}/${{ steps.calc.outputs.archive }}" + - name: 'Set output variables' + id: final + shell: pwsh + run: | + echo "${{ runner.temp }}/ninja-${{ inputs.version }}-${{ runner.arch }}" >> $env:GITHUB_PATH diff --git a/.github/workflows/CMake-MSVC-noyasm.yml b/.github/workflows/CMake-MSVC-noyasm.yml index 81cfad30..00bb68f5 100644 --- a/.github/workflows/CMake-MSVC-noyasm.yml +++ b/.github/workflows/CMake-MSVC-noyasm.yml @@ -22,9 +22,10 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 with: arch: ${{ matrix.arch }} - - name: Install ninja - uses: turtlesec-no/get-ninja@main + sdK: ${{ (matrix.arch == 'amd64_arm' && '10.0.22621.0') || '' }} + - name: Setup ninja + uses: ./.github/actions/setup-ninja - name: CMake (configure) - run: cmake -S ports\cmake -B build -GNinja -DBUILD_SHARED_LIBS=${{ matrix.shared }} . + run: cmake -S ports\cmake -B build -GNinja -DBUILD_SHARED_LIBS=${{ matrix.shared }} - name: CMake --build run: cmake --build build diff --git a/.github/workflows/CMake-MSVC.yml b/.github/workflows/CMake-MSVC.yml index abb6d840..1125b73b 100644 --- a/.github/workflows/CMake-MSVC.yml +++ b/.github/workflows/CMake-MSVC.yml @@ -24,9 +24,9 @@ jobs: uses: ilammy/msvc-dev-cmd@v1 with: arch: x64 - - name: Install ninja + - name: Setup ninja if: ${{ !steps.restore-yasm.outputs.cache-hit }} - uses: turtlesec-no/get-ninja@main + uses: ./.github/actions/setup-ninja - name: Build and install yasm if: ${{ !steps.restore-yasm.outputs.cache-hit }} run: | @@ -71,8 +71,8 @@ jobs: with: arch: ${{ matrix.arch }} sdK: ${{ (matrix.arch == 'amd64_arm' && '10.0.22621.0') || '' }} - - name: Install ninja - uses: turtlesec-no/get-ninja@main + - name: Setup ninja + uses: ./.github/actions/setup-ninja - name: CMake (configure) run: cmake -S ports/cmake -B build -GNinja -DYASM_ASSEMBLER=${{ github.workspace }}/yasm/bin/vsyasm.exe -DBUILD_SHARED_LIBS=${{ matrix.shared }} - name: CMake (Build)