Skip to content

Master

Master #67

Workflow file for this run

name: CMake
on:
push:
branches: [ "master", "dev", "dev-*" ]
pull_request:
branches: [ "master", "dev" ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# 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
outputs:
version: ${{ steps.get_version.outputs._version }}
steps:
- name: Add MSBuild to PATH
uses: microsoft/[email protected]
- uses: actions/checkout@v3
- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}/build
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest -C ${{env.BUILD_TYPE}}
- name: Install
working-directory: ${{github.workspace}}/build
# Install the project to the build/install directory
run: cmake --install . --prefix install
- name: Get the Version
id: get_version
run: |
$version = (Get-Content -Path ${{github.workspace}}/resource/version.ver -TotalCount 1).Trim()
echo "dll version: $version"
echo "_version=$version" >> $env:GITHUB_OUTPUT
- name: Zip the Install Directory
uses: montudor/[email protected]
with:
args: -r -9 -y
files: ${{github.workspace}}/build/install/*
output: ${{github.workspace}}/build/libocr-${{ steps.get_version.outputs._version }}.zip
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
# Artifact name
name: libocr
path: ${{github.workspace}}/build/libocr-${{ steps.get_version.outputs._version }}.zip
release:
if: github.ref == 'refs/heads/master'
needs: build
runs-on: ubuntu-latest
steps:
- name: Download a Build Artifact
uses: actions/download-artifact@v2
with:
name: libocr
path: ${{github.workspace}}/build
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
Version: ${{ needs.build.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.Version }}
release_name: libocr ${{ env.Version }}
draft: false
# 仅有master分支的才不是预发布
prerelease: ${{ startsWith(github.base_ref, 'master') == false }}
- name: Upload a Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_name: libocr-${{ env.Version }}.zip
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{github.workspace}}/build/libocr-${{ env.Version }}.zip
asset_content_type: application/x-msdownload