From b957b4426fe0663be535fa95cd757b9258dad99b Mon Sep 17 00:00:00 2001 From: tomwillow Date: Mon, 9 Dec 2024 23:27:35 +0800 Subject: [PATCH] [workflow] add release job --- .github/workflows/cmake-single-platform.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-single-platform.yml b/.github/workflows/cmake-single-platform.yml index 9d46d23..54bcc98 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,25 @@ 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 - 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: | + ${{github.workspace}}/../build_SmartCharsetConverter/Release/SmartCharsetConverter.exe \ No newline at end of file