From ae675a37313e815d4d8389560486e79e670eb60a Mon Sep 17 00:00:00 2001 From: xychen Date: Fri, 17 Jun 2022 13:33:48 +0800 Subject: [PATCH] =?UTF-8?q?github:=20=E4=BC=98=E5=8C=96=20build-win32=20?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/setup-mingw64/action.yml | 42 ++++++++++++++++++++++++ .github/workflows/build.yml | 11 +++---- 2 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 .github/actions/setup-mingw64/action.yml diff --git a/.github/actions/setup-mingw64/action.yml b/.github/actions/setup-mingw64/action.yml new file mode 100644 index 0000000..a4526d1 --- /dev/null +++ b/.github/actions/setup-mingw64/action.yml @@ -0,0 +1,42 @@ +name: Setup MINGW64 + +inputs: + install: + description: 'Additional packages to install' + required: false + +outputs: + shell: + description: 'Shell to be used by other steps' + value: msys2 {0} + +runs: + using: composite + steps: + - run: | + echo '${{ inputs.install }}' | tr ' ' '\n' | sort > cache-key + date -u '+%Y%m' >> cache-key + shell: bash + - uses: actions/cache@v3 + id: cache-mingw64 + with: + path: D:\msys64 + key: mingw64-${{ hashFiles('cache-key') }} + - if: steps.cache-mingw64.outputs.cache-hit != 'true' + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + release: true + install: ${{ inputs.install }} + location: D:\ + - if: steps.cache-mingw64.outputs.cache-hit == 'true' + run: | + echo 'D:/msys64/usr/bin' >> $GITHUB_PATH + echo 'MSYSTEM=MINGW64' >> $GITHUB_ENV + echo 'MSYS2_PATH_TYPE=minimal' >> $GITHUB_ENV + echo 'CHERE_INVOKING=1' >> $GITHUB_ENV + MSYS2_CMD=D:/msys64/usr/bin/msys2.cmd + printf '@echo off\r\n' >> $MSYS2_CMD + printf 'setlocal\r\n' >> $MSYS2_CMD + printf 'D:\\msys64\\usr\\bin\\bash.exe -leo pipefail %%*\r\n' >> $MSYS2_CMD + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d646a7..2171cc6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -100,11 +100,10 @@ jobs: fetch-depth: 0 submodules: recursive - - name: Setup MSYS2 - uses: msys2/setup-msys2@v2 + - name: Setup MinGW-w64 + id: setup-mingw64 + uses: ./.github/actions/setup-mingw64 with: - msystem: MINGW64 - release: false install: >- git zip @@ -116,7 +115,7 @@ jobs: uses: ./.github/actions/cmake-build with: run-tests: true - shell: msys2 {0} + shell: ${{ steps.setup-mingw64.outputs.shell }} - name: Upload artifacts uses: actions/upload-artifact@v2 @@ -129,7 +128,7 @@ jobs: if: ${{ startsWith(github.ref, 'refs/tags/v') }} uses: ./.github/actions/release-zip with: - shell: msys2 {0} + shell: ${{ steps.setup-mingw64.outputs.shell }} name: cskburn-${{ matrix.name }}.zip root-dir: build/cskburn files: cskburn.exe