diff --git a/.github/workflows/cmake-single-platform.yml b/.github/workflows/cmake-single-platform.yml index 9d46d23..f4dd99f 100644 --- a/.github/workflows/cmake-single-platform.yml +++ b/.github/workflows/cmake-single-platform.yml @@ -7,13 +7,15 @@ on: branches: [ "master", "dev" ] pull_request: 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 @@ -36,10 +38,27 @@ jobs: - name: Build # Build your program with the given configuration - run: cmake --build --preset=default --config ${{env.BUILD_TYPE}} --target SmartCharsetConverter CoreUnitTest + 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}} + # 只有在创建标签时才执行发布操作 + release: + needs: build-and-test + if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/') + runs-on: windows-latest + + steps: + - name: Release + uses: softprops/action-gh-release@v2 + with: + name: SmartCharsetConverter ${{github.ref_name}} + fail_on_unmatched_files: true + draft: true + files: | + D:\a\SmartCharsetConverter\build_SmartCharsetConverter\Release\SmartCharsetConverter.exe \ No newline at end of file