-
-
Notifications
You must be signed in to change notification settings - Fork 51
Add metadata saving and registration for release assets #1424
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
Open
yuto-trd
wants to merge
1
commit into
main
Choose a base branch
from
feat/auto-register-release
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| name: Register Release Assets | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| env: | ||
| API_URL: https://release.api.beutl.beditor.net | ||
|
|
||
| jobs: | ||
| register-assets: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Get OIDC Token | ||
| id: oidc | ||
| run: | | ||
| TOKEN=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \ | ||
| "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://github.com/b-editor/beutl" \ | ||
| | jq -r '.value') | ||
| echo "token=$TOKEN" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Download metadata from release | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| # assets_metadata.jsonをリリースアセットからダウンロード | ||
| gh release download "${{ github.event.release.tag_name }}" \ | ||
| --repo "${{ github.repository }}" \ | ||
| --pattern "assets_metadata.json" \ | ||
| --output assets_metadata.json | ||
|
|
||
| echo "Downloaded metadata:" | ||
| cat assets_metadata.json | jq . | ||
|
|
||
| - name: Get release assets URLs | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| # リリースアセットのURL情報を取得 | ||
| gh api "repos/${{ github.repository }}/releases/${{ github.event.release.id }}/assets" > release_assets.json | ||
|
|
||
| echo "Release assets:" | ||
| cat release_assets.json | jq -r '.[].name' | ||
|
|
||
| - name: Build request payload | ||
| run: | | ||
| # assets_metadata.jsonの各エントリにURLを追加 | ||
| # ファイル名のパターンマッチングでURLを特定 | ||
|
|
||
| jq -c '.[]' assets_metadata.json | while read -r metadata; do | ||
| ID=$(echo "$metadata" | jq -r '.id') | ||
| OS=$(echo "$metadata" | jq -r '.os') | ||
| ARCH=$(echo "$metadata" | jq -r '.arch') | ||
| TYPE=$(echo "$metadata" | jq -r '.type') | ||
| VERSION=$(echo "$metadata" | jq -r '.version') | ||
| STANDALONE=$(echo "$metadata" | jq -r '.standalone') | ||
|
|
||
| # ファイル名パターンを生成してURLを検索 | ||
| URL="" | ||
| case "$TYPE" in | ||
| zip) | ||
| if [ "$STANDALONE" = "true" ]; then | ||
| PATTERN="Beutl-${OS}-${ARCH}-standalone-${VERSION}.zip" | ||
| else | ||
| PATTERN="Beutl-${OS}-${ARCH}-${VERSION}.zip" | ||
| fi | ||
| URL=$(jq -r --arg pattern "$PATTERN" '.[] | select(.name == $pattern) | .browser_download_url' release_assets.json) | ||
| ;; | ||
| installer) | ||
| if [ "$STANDALONE" = "true" ]; then | ||
| PATTERN="beutl-standalone-setup.exe" | ||
| else | ||
| PATTERN="beutl-setup.exe" | ||
| fi | ||
| URL=$(jq -r --arg pattern "$PATTERN" '.[] | select(.name == $pattern) | .browser_download_url' release_assets.json) | ||
| ;; | ||
| app) | ||
| PATTERN="Beutl.${OS}_${ARCH}.app.zip" | ||
| URL=$(jq -r --arg pattern "$PATTERN" '.[] | select(.name == $pattern) | .browser_download_url' release_assets.json) | ||
| ;; | ||
| debian) | ||
| # debパッケージはバージョン形式が異なる | ||
| URL=$(jq -r '.[] | select(.name | endswith(".deb")) | .browser_download_url' release_assets.json) | ||
| ;; | ||
| esac | ||
|
|
||
| if [ -n "$URL" ] && [ "$URL" != "null" ]; then | ||
| echo "$metadata" | jq --arg url "$URL" '. + {url: $url}' | ||
| else | ||
| echo "Warning: Could not find URL for $TYPE ($OS-$ARCH, standalone=$STANDALONE)" >&2 | ||
| fi | ||
| done | jq -s '.' > assets_with_urls.json | ||
|
|
||
| echo "" | ||
| echo "Assets with URLs:" | ||
| cat assets_with_urls.json | jq . | ||
|
|
||
| # リクエストペイロードを作成 | ||
| jq '{assets: .}' assets_with_urls.json > request_payload.json | ||
|
|
||
| echo "" | ||
| echo "Request payload:" | ||
| cat request_payload.json | jq . | ||
|
|
||
| - name: Register release assets | ||
| env: | ||
| OIDC_TOKEN: ${{ steps.oidc.outputs.token }} | ||
| run: | | ||
| # APIを呼び出し | ||
| RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ | ||
| -H "Authorization: Bearer $OIDC_TOKEN" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d @request_payload.json \ | ||
| "$API_URL/releases/bulk") | ||
|
|
||
| HTTP_CODE=$(echo "$RESPONSE" | tail -n1) | ||
| BODY=$(echo "$RESPONSE" | sed '$d') | ||
|
|
||
| echo "" | ||
| echo "Response code: $HTTP_CODE" | ||
| echo "Response body: $BODY" | ||
|
|
||
| if [ "$HTTP_CODE" -ne 201 ]; then | ||
| echo "::error::API call failed with status $HTTP_CODE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "::notice::Successfully registered release assets" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new metadata download step relies on
actions/download-artifactwithout arun-id, so it only searches the current release job formetadata-*artifacts. All metadata artifacts are produced by the reusable build workflows (build-executable, build-windows-installer, build-debian-package, build-macos-app) which run under different run IDs and are already exposed viaartifact-run-idoutputs. Without passing those run IDs here, this step will fail with “No artifacts found” before the release is created, blocking the release pipeline whenever metadata artifacts are needed.Useful? React with 👍 / 👎.