Skip to content

Commit

Permalink
Merge branch 'cache-librime' into pb
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Feb 22, 2024
2 parents c7bee7c + a2577c0 commit b9d5b58
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 19 deletions.
42 changes: 31 additions & 11 deletions .github/workflows/commit-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,48 @@ jobs:
BOOST_ROOT: ${{ github.workspace }}\deps\boost_1_83_0
steps:
- name: Checkout last commit
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure build environment
shell: bash
run: |
copy env.vs2022.bat env.bat
$git_ref_name = git describe --always
echo "git_ref_name=$git_ref_name" >> $env:GITHUB_ENV
cp env.vs2022.bat env.bat
librime_id=$(git submodule foreach --quiet 'if [ $name == "librime" ]; then echo `git rev-parse HEAD`; fi')
echo "librime_id is $librime_id"
echo "librime_id=$librime_id" >> $GITHUB_ENV
- name: Cache Boost
id: cache-boost
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ env.BOOST_ROOT }}
key: ${{ runner.os }}-boost-${{ env.boost_version }}

# install boost if not cached
- name: Install Boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: .\install_boost.bat

# add msbuild to PATH
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1.3
uses: microsoft/setup-msbuild@v2

- name: Copy Rime files
if: env.librime_build == 'stable'
run: .\github.install.bat
# cache librime
- name: Cache librime
if: env.librime_build == 'submodule'
id: cache-librime
uses: actions/cache@v4
with:
path: |
librime
key: ${{ runner.os }}-librime-${{ env.librime_id }}

# build librime if not cached
- name: Build librime
if: env.librime_build == 'submodule'
if: ${{ env.librime_build == 'submodule' && steps.cache-librime.outputs.cache-hit != 'true' }}
env:
RIME_PLUGINS: hchunhui/librime-lua lotem/librime-octagram rime/librime-predict
shell: bash
Expand All @@ -63,6 +74,15 @@ jobs:
popd
./build.bat librime
# build librime if cached
- name: Copy librime built files cached
if: ${{ env.librime_build == 'submodule' && steps.cache-librime.outputs.cache-hit == 'true' }}
shell: bash
run: |
cp ./librime/dist/lib/rime* ./lib/
cp ./librime/dist/lib/rime.dll ./output/
cp ./librime/dist/include/*.h ./include/
- name: Build Weasel
id: build_weasel
shell: bash
Expand All @@ -77,7 +97,7 @@ jobs:
Compress-Archive -Path output\*.pdb -CompressionLevel Optimal -DestinationPath .\output\archives\symbols.zip
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
path: |
Expand Down
44 changes: 36 additions & 8 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,55 @@ jobs:
BOOST_ROOT: ${{ github.workspace }}\deps\boost_1_83_0
steps:
- name: Checkout last commit
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure build environment
shell: bash
run: |
copy env.vs2022.bat env.bat
$git_ref_name = git describe --always
echo "git_ref_name=$git_ref_name" >> $env:GITHUB_ENV
cp env.vs2022.bat env.bat
librime_id=$(git submodule foreach --quiet 'if [ $name == "librime" ]; then echo `git rev-parse HEAD`; fi')
echo "librime_id is $librime_id"
echo "librime_id=$librime_id" >> $GITHUB_ENV
# cache boost
- name: Cache Boost
id: cache-boost
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
${{ env.BOOST_ROOT }}
key: ${{ runner.os }}-boost-${{ env.boost_version }}

# install boost if not cached
- name: Install Boost
if: steps.cache-boost.outputs.cache-hit != 'true'
run: .\install_boost.bat

# add msbuild to PATH
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1.3
uses: microsoft/setup-msbuild@v2

# use upper stream released librime files if stable release
- name: Copy Rime files
if: env.librime_build == 'stable'
if: ${{ startsWith(github.ref, 'refs/tags/') || env.librime_build == 'stable' }}
run: |
.\github.install.bat
# cache librime for nightly build and not stable release
- name: Cache librime
if: ${{ github.ref == 'refs/heads/master' && env.librime_build == 'submodule' }}
id: cache-librime
uses: actions/cache@v4
with:
path: |
librime
key: ${{ runner.os }}-librime-${{ env.librime_id }}

# build librime if not cached for nightly build and not stable release
- name: Build librime
if: env.librime_build == 'submodule'
if: ${{ github.ref == 'refs/heads/master' && env.librime_build == 'submodule' && steps.cache-librime.outputs.cache-hit != 'true' }}
env:
RIME_PLUGINS: hchunhui/librime-lua lotem/librime-octagram rime/librime-predict
shell: bash
Expand All @@ -61,6 +78,15 @@ jobs:
popd
./build.bat librime
# build librime if cached
- name: Copy librime built files cached
if: ${{ github.ref == 'refs/heads/master' && env.librime_build == 'submodule' && steps.cache-librime.outputs.cache-hit == 'true' }}
shell: bash
run: |
cp ./librime/dist/lib/rime* ./lib/
cp ./librime/dist/lib/rime.dll ./output/
cp ./librime/dist/include/*.h ./include/
- name: Build Weasel
id: build_weasel
shell: bash
Expand All @@ -80,6 +106,7 @@ jobs:
.\extract_changelog.ps1
if: startsWith(github.ref, 'refs/tags/')

# create nightly release
- name: Create Nightly release
if: github.ref == 'refs/heads/master'
uses: 'marvinpinto/action-automatic-releases@latest'
Expand All @@ -92,6 +119,7 @@ jobs:
./output/archives/weasel*.exe
./output/archives/symbols.zip
# create stable release
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
Expand Down

0 comments on commit b9d5b58

Please sign in to comment.