Skip to content

Commit

Permalink
[workflow] add release job
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwillow committed Dec 12, 2024
1 parent cf5072c commit ac9c768
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 29 deletions.
82 changes: 57 additions & 25 deletions .github/workflows/cmake-single-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,74 @@ name: Build On Windows

on:
push:
branches: [ "master", "dev" ]
branches: ["master", "dev"]
pull_request:
branches: [ "master" ]
branches: ["master"]
# 当创建标签时也触发此工作流
create:

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
build-and-test:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Setup anew (or from cache) vcpkg (and does not build any package)
uses: lukka/run-vcpkg@v11 # Always specify the specific _version_ of the
# action you need, `v11` in this case to stay up
# to date with fixes on the v11 branch.
with:
doNotCache: false

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake --preset=default -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build --preset=default --config ${{env.BUILD_TYPE}} --target SmartCharsetConverter CoreUnitTest

- name: Test
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --preset=default -C ${{env.BUILD_TYPE}}
- uses: actions/checkout@v4

- name: Setup anew (or from cache) vcpkg (and does not build any package)
uses:
lukka/run-vcpkg@v11 # Always specify the specific _version_ of the
# action you need, `v11` in this case to stay up
# to date with fixes on the v11 branch.
with:
doNotCache: false

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake --preset=default -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: |
cmake --build --preset=default --config ${{env.BUILD_TYPE}} --target SmartCharsetConverter
cmake --build --preset=default --config ${{env.BUILD_TYPE}} --target CoreUnitTest
- name: Test
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --preset=default -C ${{env.BUILD_TYPE}}

- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: build/Release/SmartCharsetConverter.exe

# 只有在创建标签时才执行发布操作
release:
needs: build-and-test
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/')
runs-on: windows-latest

steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: ./

- name: Release
uses: softprops/action-gh-release@v2
with:
name: SmartCharsetConverter ${{github.ref_name}}
fail_on_unmatched_files: true
draft: true
files: |
./SmartCharsetConverter.exe
2 changes: 1 addition & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"version": 4,
"configurePresets": [{
"name": "default",
"binaryDir": "${sourceDir}/../build_SmartCharsetConverter",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
Expand Down
2 changes: 1 addition & 1 deletion README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ v0.9.1 bugfix: fixed the error of "ucnv error. code=11" due to invalid trucated
1. Confirm the compilation environment: win10+ x64, Visual Studio 2019+, cmake.
2. Install vcpkg and set correct environment variable VCPKG_ROOT.
3. Execute config_on_win.bat to generate .sln.
4. Open ../build_SmartCharsetConverter/SmartCharsetConverter.sln.
4. Open ./build/SmartCharsetConverter.sln.

# Add language pack

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ v0.9.1 bugfix: 修复由于截取字符片段导致的"ucnv error. code=11"出
# 构建方法

1. 确认编译环境:win10+ x64, Visual Studio 2019+, cmake。
2. 安装 vcpkg,正确设置VCPKG_ROOT环境变量
2. 安装 vcpkg,正确设置 VCPKG_ROOT 环境变量
3. 执行 config_on_win.bat 生成.sln。
4. 打开 ../build_SmartCharsetConverter/SmartCharsetConverter.sln。
4. 打开 ./build/SmartCharsetConverter.sln。

# 添加语言包

Expand Down

0 comments on commit ac9c768

Please # to comment.