|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '*' |
| 7 | + tags: |
| 8 | + - '[0-9]+.*' |
| 9 | + pull_request: |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + runs-on: ubuntu-22.04 |
| 15 | + steps: |
| 16 | + - name: Checkout last commit |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Install clang-format 18 |
| 20 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 21 | + run: | |
| 22 | + wget https://apt.llvm.org/llvm-snapshot.gpg.key |
| 23 | + sudo gpg --dearmor < llvm-snapshot.gpg.key > /usr/share/keyrings/llvm-archive-keyring.gpg |
| 24 | + echo "deb [signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" | sudo tee /etc/apt/sources.list.d/llvm-toolchain-jammy-18.list |
| 25 | + sudo apt-get update |
| 26 | + sudo apt-get install -y clang-format-18 |
| 27 | + sudo ln -sf /usr/bin/clang-format-18 /usr/local/bin/clang-format |
| 28 | + clang-format --version |
| 29 | +
|
| 30 | + - name: Code style lint |
| 31 | + if: ${{ !startsWith(github.ref, 'refs/tags/') }} |
| 32 | + shell: bash |
| 33 | + run: ./clang-format.sh -i |
| 34 | + |
| 35 | + build: |
| 36 | + needs: lint |
| 37 | + runs-on: windows-2022 |
| 38 | + env: |
| 39 | + boost_version: 1.84.0 |
| 40 | + BOOST_ROOT: ${{ github.workspace }}\deps\boost_1_84_0 |
| 41 | + SDKVER: 10.0.19041.0 |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + variant: [msbuild, xmake] |
| 45 | + steps: |
| 46 | + - name: Checkout last commit |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + submodules: true |
| 50 | + fetch-depth: 0 |
| 51 | + |
| 52 | + - name: Fetch all tags |
| 53 | + run: git fetch --tags |
| 54 | + |
| 55 | + - name: Configure build environment |
| 56 | + shell: bash |
| 57 | + run: | |
| 58 | + cp env.vs2022.bat env.bat |
| 59 | + echo git_ref_name="$(git describe --always)" >> $GITHUB_ENV |
| 60 | +
|
| 61 | + - name: Cache Boost |
| 62 | + id: cache-boost |
| 63 | + uses: actions/cache@v4 |
| 64 | + with: |
| 65 | + path: | |
| 66 | + ${{ env.BOOST_ROOT }} |
| 67 | + key: ${{ runner.os }}-boost-${{ env.boost_version }} |
| 68 | + |
| 69 | + - name: Install Boost |
| 70 | + if: steps.cache-boost.outputs.cache-hit != 'true' |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + ./install_boost.bat |
| 74 | + ./build.bat boost arm64 |
| 75 | +
|
| 76 | + - uses: ilammy/msvc-dev-cmd@v1 |
| 77 | + with: |
| 78 | + sdk: ${{ env.SDKVER }} |
| 79 | + |
| 80 | + # bundled winsparkle v0.9.2 to disable auto open ReleaseNoteUrl in default browser |
| 81 | + - name: cache bundled winsparkle |
| 82 | + id: cache-winsparkle |
| 83 | + uses: actions/cache@v4 |
| 84 | + with: |
| 85 | + path: | |
| 86 | + ${{ github.workspace }}\winsparkle\x64\Release\WinSparkle.dll |
| 87 | + ${{ github.workspace }}\winsparkle\x64\Release\WinSparkle.lib |
| 88 | + ${{ github.workspace }}\winsparkle\Release\WinSparkle.dll |
| 89 | + ${{ github.workspace }}\winsparkle\Release\WinSparkle.lib |
| 90 | + key: ${{ runner.os }}-winsparkle-v0.9.2-bundled |
| 91 | + restore-keys: | |
| 92 | + winsparkle-v0.9.2-bundled |
| 93 | +
|
| 94 | + - name: Build bundled winsparkle |
| 95 | + if: steps.cache-winsparkle.outputs.cache-hit != 'true' |
| 96 | + shell: pwsh |
| 97 | + run: | |
| 98 | + $ErrorActionPreference = 'Stop' |
| 99 | + if (Test-Path winsparkle) { Remove-Item -Recurse -Force winsparkle } |
| 100 | + # Clone winsparkle repo v0.9.2 |
| 101 | + git clone https://github.com/vslavik/winsparkle.git -b v0.9.2 --depth 1 |
| 102 | + cd winsparkle |
| 103 | + git submodule update --init --recursive |
| 104 | + copy ..\bundled_winsparkle.patch . |
| 105 | + git apply bundled_winsparkle.patch |
| 106 | + nuget restore |
| 107 | + msbuild -m -t:Build -p:Configuration=Release -p:Platform=x64 WinSparkle.sln |
| 108 | + msbuild -m -t:Build -p:Configuration=Release -p:Platform=Win32 WinSparkle.sln |
| 109 | +
|
| 110 | + - name: Install WinSparkle files |
| 111 | + shell: pwsh |
| 112 | + run: | |
| 113 | + $ErrorActionPreference = 'Stop' |
| 114 | + copy .\winsparkle\x64\Release\WinSparkle.dll .\output\ |
| 115 | + copy .\winsparkle\x64\Release\WinSparkle.lib .\lib64\ |
| 116 | + copy .\winsparkle\Release\WinSparkle.dll .\output\Win32\ |
| 117 | + copy .\winsparkle\Release\WinSparkle.lib .\lib\ |
| 118 | +
|
| 119 | + - name: Get Rime files |
| 120 | + shell: pwsh |
| 121 | + run: | |
| 122 | + $ErrorActionPreference = 'Stop' |
| 123 | + .\get-rime.ps1 -use dev |
| 124 | +
|
| 125 | + - name: Build data |
| 126 | + shell: pwsh |
| 127 | + run: | |
| 128 | + $ErrorActionPreference = 'Stop' |
| 129 | + .\build.bat data |
| 130 | +
|
| 131 | + - name: Setup xmake |
| 132 | + if: matrix.variant == 'xmake' |
| 133 | + uses: xmake-io/github-action-setup-xmake@v1 |
| 134 | + |
| 135 | + - name: Build Weasel |
| 136 | + shell: pwsh |
| 137 | + id: build_weasel |
| 138 | + env: |
| 139 | + RELEASE_BUILD: ${{ (github.repository == 'rime/weasel' && startsWith(github.ref, 'refs/tags/')) && '1' || '' }} |
| 140 | + run: | |
| 141 | + $ErrorActionPreference = 'Stop' |
| 142 | + if ('${{ matrix.variant }}' -eq 'msbuild') { |
| 143 | + .\build.bat arm64 installer |
| 144 | + } else { |
| 145 | + .\xbuild.bat arm64 installer |
| 146 | + } |
| 147 | +
|
| 148 | + - name: Compress Debug Symbols |
| 149 | + if: matrix.variant == 'msbuild' |
| 150 | + shell: pwsh |
| 151 | + run: | |
| 152 | + $ErrorActionPreference = 'Stop' |
| 153 | + output\7z.exe a -t7z "./output/archives/debug_symbols.7z" "output/*.pdb" -r |
| 154 | +
|
| 155 | + - name: Upload artifacts |
| 156 | + if: matrix.variant == 'msbuild' |
| 157 | + uses: actions/upload-artifact@v4 |
| 158 | + with: |
| 159 | + name: weasel-artifact-${{ env.git_ref_name }} |
| 160 | + if-no-files-found: error |
| 161 | + path: | |
| 162 | + .\output\archives\weasel*.exe |
| 163 | + .\output\archives\debug_symbols.7z |
| 164 | +
|
| 165 | + # Release-only steps (run on tags or master) |
| 166 | + - name: Extract changelog |
| 167 | + if: ${{ github.repository == 'rime/weasel' && startsWith(github.ref, 'refs/tags/') && matrix.variant == 'msbuild' }} |
| 168 | + shell: pwsh |
| 169 | + run: .\extract_changelog.ps1 |
| 170 | + |
| 171 | + - name: Create Nightly release |
| 172 | + if: ${{ github.repository == 'rime/weasel' && github.ref == 'refs/heads/master' && matrix.variant == 'msbuild' }} |
| 173 | + uses: 'marvinpinto/action-automatic-releases@latest' |
| 174 | + with: |
| 175 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 176 | + automatic_release_tag: latest |
| 177 | + prerelease: true |
| 178 | + title: "Nightly Build" |
| 179 | + files: | |
| 180 | + ./output/archives/weasel*.exe |
| 181 | + ./output/archives/debug_symbols.7z |
| 182 | +
|
| 183 | + - name: Release (stable) |
| 184 | + if: ${{ github.repository == 'rime/weasel' && startsWith(github.ref, 'refs/tags/') && matrix.variant == 'msbuild' }} |
| 185 | + uses: softprops/action-gh-release@v2 |
| 186 | + with: |
| 187 | + draft: true |
| 188 | + files: | |
| 189 | + ./output/archives/weasel*.exe |
| 190 | + ./output/archives/debug_symbols.7z |
| 191 | + body_path: ${{ github.workspace }}/RELEASE_CHANGELOG.md |
0 commit comments