From f30239065a84dfebda7472032f423dee4d69ad43 Mon Sep 17 00:00:00 2001 From: Hiroshiba Date: Tue, 11 Apr 2023 01:53:28 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E3=82=92=E5=8F=AF=E8=83=BD=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B=20(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 47 ++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1335a3d..a507228 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,21 @@ on: types: - published workflow_dispatch: + inputs: + version: + description: "バージョン情報(A.BB.C / A.BB.C-preview.D)" + required: true + release: + description: "リリースするかどうか" + type: boolean + +env: + ONNXRUNTIME_VERSION: + |- # releaseタグ名か、workflow_dispatchでのバージョン名が入る。無指定なら適当なバージョン + ${{ github.event.release.tag_name || github.event.inputs.version || '1.14.0' }} + RELEASE: + |- # releaseタグ名か、workflow_dispatchでのreleaseフラグがあればリリースする + ${{ github.event.release.tag_name != '' || github.event.inputs.release == 'true' }} jobs: build-onnxruntime: @@ -17,8 +32,8 @@ jobs: include: - artifact_name: onnxruntime-linux-armhf os: ubuntu-20.04 - cc_version: '8' - cxx_version: '8' + cc_version: "8" + cxx_version: "8" arch: arm-linux-gnueabihf symlink_workaround: true build_opts: --arm --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=armv7l --config Release --parallel --update --build --build_shared_lib @@ -26,8 +41,8 @@ jobs: release_config: Release - artifact_name: onnxruntime-linux-arm64 os: ubuntu-20.04 - cc_version: '8' - cxx_version: '8' + cc_version: "8" + cxx_version: "8" arch: aarch64-linux-gnu symlink_workaround: true build_opts: --arm64 --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=aarch64 --config Release --parallel --update --build --build_shared_lib @@ -50,7 +65,6 @@ jobs: release_config: Release-iphonesimulator env: - ONNXRUNTIME_VERSION: 1.14.1 # prefix usage: "", "arm-linux-gnueabihf-" => "gcc-8", "arm-linux-gnueabihf-gcc-8" (command name) # suffix usage: "", "-arm-linux-gnueabihf" => "gcc-8", "gcc-8-arm-linux-gnueabihf" (package name) ARCH_PREFIX: "${{ (matrix.arch != '' && matrix.arch) || '' }}${{ (matrix.arch != '' && '-') || '' }}" @@ -59,6 +73,17 @@ jobs: runs-on: ${{ matrix.os }} steps: + - name: Version check (semver) + shell: bash + run: | + VERSION="${{ env.ONNXRUNTIME_VERSION }}" + if [[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?(\+([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$ ]]; then + echo "Version: $VERSION" + else + echo "$VERSION is not a valid semver." + exit 1 + fi + - name: Checkout uses: actions/checkout@v2 with: @@ -90,7 +115,7 @@ jobs: gcc-${{ matrix.cc_version }}${{ env.ARCH_SUFFIX }} \ g++-${{ matrix.cxx_version }}${{ env.ARCH_SUFFIX }} \ python3 - + # ONNX Runtime v1.14.1 requires CMake 3.24 or higher. - name: Install CMake if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu') @@ -117,7 +142,7 @@ jobs: # Set environment variable CC / CXX echo "CC=${{ env.ARCH_PREFIX }}gcc-${{ matrix.cc_version }}" >> "$GITHUB_ENV" echo "CXX=${{ env.ARCH_PREFIX }}g++-${{ matrix.cxx_version }}" >> "$GITHUB_ENV" - + - name: Build ONNX Runtime if: steps.cache-build-result.outputs.cache-hit != 'true' run: | @@ -159,20 +184,20 @@ jobs: retention-days: 14 - name: Generate RELEASE_NAME - if: github.event.release.tag_name != '' # If release + if: env.RELEASE == 'true' run: | echo "RELEASE_NAME=${{ matrix.artifact_name }}-${{ env.ONNXRUNTIME_VERSION }}" >> $GITHUB_ENV - name: Rearchive artifact - if: github.event.release.tag_name != '' # If release + if: env.RELEASE == 'true' run: | mv artifact/ "${{ env.RELEASE_NAME }}" tar cfz "${{ env.RELEASE_NAME }}.tgz" "${{ env.RELEASE_NAME }}/" - name: Upload to Release - if: github.event.release.tag_name != '' # If release + if: env.RELEASE == 'true' uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.ref }} # ==> github.event.release.tag_name + tag: ${{ env.ONNXRUNTIME_VERSION }} # ==> github.event.release.tag_name file: ${{ env.RELEASE_NAME }}.tgz