Skip to content

Commit

Permalink
add: リリースノートに機械可読な<table>を置く (#43)
Browse files Browse the repository at this point in the history
* add: リリースノートに機械可読な`<table>`を置く

* `<table>`の組み立てを`build-spec-table`に集約する

<#43 (comment)>

* `data-*`属性に情報を書く

<VOICEVOX/voicevox_core#810 (comment)>

* fixup! `data-*`属性に情報を書く

* "アーキテクチャ"に統一する

<#43 (comment)>
  • Loading branch information
qryxip authored Aug 3, 2024
1 parent fa10941 commit bc8e892
Showing 1 changed file with 129 additions and 2 deletions.
131 changes: 129 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,55 @@ jobs:
path: artifact/*

- name: Generate RELEASE_NAME
if: env.RELEASE == 'true'
run: |
echo "RELEASE_NAME=${{ matrix.artifact_name }}-${{ env.ONNXRUNTIME_VERSION }}" >> "$GITHUB_ENV"
- name: Generate specifications
run: |
build_opts=(${{ matrix.build_opts }})
for arg in "${build_opts[@]}"; do
case "$arg" in
CMAKE_SYSTEM_NAME=Windows) os=Windows ;;
CMAKE_SYSTEM_NAME=Linux) os=Linux ;;
CMAKE_SYSTEM_NAME=Darwin) os=macOS ;;
--android) os=Android ;;
--ios) os=iOS ;;
CMAKE_SYSTEM_PROCESSOR=x86_64 | CMAKE_OSX_ARCHITECTURES=x86_64 | x86_64) arch=x86_64 ;;
--x86) arch=x86 ;;
CMAKE_OSX_ARCHITECTURES=arm64 | --arm64 | arm64 | arm64-v8a) arch=AArch64 ;;
--arm) arch=ARMv7 ;;
--use_cuda) use_cuda=1 ;;
--use_dml) use_dml=1 ;;
esac
done
jq '
{
"os": $os,
"arch": $arch,
# ONNX Runtimeが示す順番に従う
"devices": [
("CUDA" | select($use_cuda == "1")),
("DirectML" | select($use_dml == "1")),
"CPU"
] | join("/")
}' \
-n \
--arg os "$os" \
--arg arch "$arch" \
--arg use_cuda "$use_cuda" \
--arg use_dml "$use_dml" \
> "$RELEASE_NAME.json"
- name: Upload specifications
uses: actions/upload-artifact@v4
with:
name: specs-${{ matrix.artifact_name }}
path: ${{ env.RELEASE_NAME }}.json

- name: Rearchive artifact
if: env.RELEASE == 'true'
run: |
Expand All @@ -360,10 +405,15 @@ jobs:
build-xcframework:
needs: build-onnxruntime
runs-on: macos-12
outputs:
release-name: ${{ steps.gen-envs.outputs.release-name }}
steps:
- name: Generate RELEASE_NAME and ONNXRUNTIME_BASENAME
id: gen-envs
run: |
echo "RELEASE_NAME=onnxruntime-ios-xcframework-${{ env.ONNXRUNTIME_VERSION }}" >> "$GITHUB_ENV"
RELEASE_NAME=onnxruntime-ios-xcframework-${{ env.ONNXRUNTIME_VERSION }}
echo "release-name=$RELEASE_NAME" >> "$GITHUB_OUTPUT"
echo "RELEASE_NAME=$RELEASE_NAME" >> "$GITHUB_ENV"
echo "ONNXRUNTIME_BASENAME=libonnxruntime.${{ env.ONNXRUNTIME_VERSION }}.dylib" >> "$GITHUB_ENV"
- uses: actions/checkout@v3
Expand Down Expand Up @@ -441,3 +491,80 @@ jobs:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.ONNXRUNTIME_VERSION }} # ==> github.event.release.tag_name
file: ${{ env.RELEASE_NAME }}.zip

build-spec-table:
needs: [build-onnxruntime, build-xcframework]
runs-on: ubuntu-22.04
steps:
- name: Download specifications
uses: actions/download-artifact@v4
with:
path: specs
pattern: specs-*
merge-multiple: true

- name: Construct release notes
run: |
release_notes=$(
cat <<EOF
## 動的ライブラリ
<table data-voicevox-onnxruntime-specs-format-version="1" data-voicevox-onnxruntime-specs-type="dylibs">
<thead>
<tr>
<th>OS</th>
<th>アーキテクチャ</th>
<th>デバイス</th>
<th>名前</th>
</tr>
</thead>
<tbody>
EOF
)
release_notes+=$'\n'
for specs_file in specs/*.json; do
specs=$(< "$specs_file")
release_name=$(basename "${specs_file%.json}")
release_notes+=$' <tr>\n'
release_notes+=" <td>$(jq .os -r <<< "$specs")</td>"$'\n'
release_notes+=" <td>$(jq .arch -r <<< "$specs")</td>"$'\n'
release_notes+=" <td>$(jq .devices -r <<< "$specs")</td>"$'\n'
release_notes+=" <td><a href=\"https://github.com/$GITHUB_REPOSITORY/releases/download/$ONNXRUNTIME_VERSION/$release_name.tgz\">$release_name.tgz</a></td>"$'\n'
release_notes+=$' </tr>\n'
done
release_notes+=$(
cat <<EOF
</tbody>
</table>
## XCFramework
<table data-voicevox-onnxruntime-specs-format-version="1" data-voicevox-onnxruntime-specs-type="xcframeworks">
<thead>
<tr>
<th>OS</th>
<th>アーキテクチャ</th>
<th>デバイス</th>
<th>名前</th>
</tr>
</thead>
<tbody>
<tr>
<td>iOS</td>
<td>AArch64/x86_64</td>
<td>CPU</td>
<td><a href="https://github.com/$GITHUB_REPOSITORY/releases/download/$ONNXRUNTIME_VERSION/${{ needs.build-xcframework.outputs.release-name }}.zip">${{ needs.build-xcframework.outputs.release-name }}.zip</a></td>
</tr>
</tbody>
</table>
EOF
)
tee release-notes.md >&2 <<< "$release_notes"
- name: Update release notes
if: env.RELEASE == 'true'
uses: softprops/action-gh-release@v2
with:
body_path: release-notes.md
prerelease: true
tag_name: ${{ env.ONNXRUNTIME_VERSION }}

0 comments on commit bc8e892

Please sign in to comment.