Skip to content

Commit f302390

Browse files
authored
バージョン指定を可能にする (#16)
1 parent b1049ed commit f302390

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

.github/workflows/build.yml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ on:
88
types:
99
- published
1010
workflow_dispatch:
11+
inputs:
12+
version:
13+
description: "バージョン情報(A.BB.C / A.BB.C-preview.D)"
14+
required: true
15+
release:
16+
description: "リリースするかどうか"
17+
type: boolean
18+
19+
env:
20+
ONNXRUNTIME_VERSION:
21+
|- # releaseタグ名か、workflow_dispatchでのバージョン名が入る。無指定なら適当なバージョン
22+
${{ github.event.release.tag_name || github.event.inputs.version || '1.14.0' }}
23+
RELEASE:
24+
|- # releaseタグ名か、workflow_dispatchでのreleaseフラグがあればリリースする
25+
${{ github.event.release.tag_name != '' || github.event.inputs.release == 'true' }}
1126

1227
jobs:
1328
build-onnxruntime:
@@ -17,17 +32,17 @@ jobs:
1732
include:
1833
- artifact_name: onnxruntime-linux-armhf
1934
os: ubuntu-20.04
20-
cc_version: '8'
21-
cxx_version: '8'
35+
cc_version: "8"
36+
cxx_version: "8"
2237
arch: arm-linux-gnueabihf
2338
symlink_workaround: true
2439
build_opts: --arm --cmake_extra_defines CMAKE_SYSTEM_NAME=Linux CMAKE_SYSTEM_PROCESSOR=armv7l --config Release --parallel --update --build --build_shared_lib
2540
result_dir: build/Linux
2641
release_config: Release
2742
- artifact_name: onnxruntime-linux-arm64
2843
os: ubuntu-20.04
29-
cc_version: '8'
30-
cxx_version: '8'
44+
cc_version: "8"
45+
cxx_version: "8"
3146
arch: aarch64-linux-gnu
3247
symlink_workaround: true
3348
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:
5065
release_config: Release-iphonesimulator
5166

5267
env:
53-
ONNXRUNTIME_VERSION: 1.14.1
5468
# prefix usage: "", "arm-linux-gnueabihf-" => "gcc-8", "arm-linux-gnueabihf-gcc-8" (command name)
5569
# suffix usage: "", "-arm-linux-gnueabihf" => "gcc-8", "gcc-8-arm-linux-gnueabihf" (package name)
5670
ARCH_PREFIX: "${{ (matrix.arch != '' && matrix.arch) || '' }}${{ (matrix.arch != '' && '-') || '' }}"
@@ -59,6 +73,17 @@ jobs:
5973
runs-on: ${{ matrix.os }}
6074

6175
steps:
76+
- name: Version check (semver)
77+
shell: bash
78+
run: |
79+
VERSION="${{ env.ONNXRUNTIME_VERSION }}"
80+
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
81+
echo "Version: $VERSION"
82+
else
83+
echo "$VERSION is not a valid semver."
84+
exit 1
85+
fi
86+
6287
- name: Checkout
6388
uses: actions/checkout@v2
6489
with:
@@ -90,7 +115,7 @@ jobs:
90115
gcc-${{ matrix.cc_version }}${{ env.ARCH_SUFFIX }} \
91116
g++-${{ matrix.cxx_version }}${{ env.ARCH_SUFFIX }} \
92117
python3
93-
118+
94119
# ONNX Runtime v1.14.1 requires CMake 3.24 or higher.
95120
- name: Install CMake
96121
if: steps.cache-build-result.outputs.cache-hit != 'true' && startsWith(matrix.os, 'ubuntu')
@@ -117,7 +142,7 @@ jobs:
117142
# Set environment variable CC / CXX
118143
echo "CC=${{ env.ARCH_PREFIX }}gcc-${{ matrix.cc_version }}" >> "$GITHUB_ENV"
119144
echo "CXX=${{ env.ARCH_PREFIX }}g++-${{ matrix.cxx_version }}" >> "$GITHUB_ENV"
120-
145+
121146
- name: Build ONNX Runtime
122147
if: steps.cache-build-result.outputs.cache-hit != 'true'
123148
run: |
@@ -159,20 +184,20 @@ jobs:
159184
retention-days: 14
160185

161186
- name: Generate RELEASE_NAME
162-
if: github.event.release.tag_name != '' # If release
187+
if: env.RELEASE == 'true'
163188
run: |
164189
echo "RELEASE_NAME=${{ matrix.artifact_name }}-${{ env.ONNXRUNTIME_VERSION }}" >> $GITHUB_ENV
165190
166191
- name: Rearchive artifact
167-
if: github.event.release.tag_name != '' # If release
192+
if: env.RELEASE == 'true'
168193
run: |
169194
mv artifact/ "${{ env.RELEASE_NAME }}"
170195
tar cfz "${{ env.RELEASE_NAME }}.tgz" "${{ env.RELEASE_NAME }}/"
171196
172197
- name: Upload to Release
173-
if: github.event.release.tag_name != '' # If release
198+
if: env.RELEASE == 'true'
174199
uses: svenstaro/upload-release-action@v2
175200
with:
176201
repo_token: ${{ secrets.GITHUB_TOKEN }}
177-
tag: ${{ github.ref }} # ==> github.event.release.tag_name
202+
tag: ${{ env.ONNXRUNTIME_VERSION }} # ==> github.event.release.tag_name
178203
file: ${{ env.RELEASE_NAME }}.tgz

0 commit comments

Comments
 (0)