Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: リリースノートに機械可読な<table>を置く #43

Merged
merged 6 commits into from
Aug 3, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 135 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
Hiroshiba marked this conversation as resolved.
Show resolved Hide resolved
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,86 @@ 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"
data-voicevox-onnxruntime-specs-onnxruntime-version="$ONNXRUNTIME_VERSION">
<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"
data-voicevox-onnxruntime-specs-onnxruntime-version="$ONNXRUNTIME_VERSION">
<thead>
<tr>
<th>OS</th>
<th>アーキテクチャ</th>
qryxip marked this conversation as resolved.
Show resolved Hide resolved
<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 }}