Update Scoop Manifest #49
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
| name: Update Scoop Manifest | |
| on: | |
| workflow_run: | |
| workflows: ["Release"] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Release tag (e.g. v0.8.0). Leave empty to use the latest release." | |
| required: false | |
| type: string | |
| jobs: | |
| update-scoop: | |
| name: Update scoop.json | |
| runs-on: ubuntu-latest | |
| # For workflow_run: only run after a successful tag release (not branch builds) | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| ( | |
| github.event.workflow_run.conclusion == 'success' && | |
| startsWith(github.event.workflow_run.head_branch, 'v') | |
| ) | |
| steps: | |
| - name: Resolve release tag | |
| id: version | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| if [ -n "${{ inputs.tag }}" ]; then | |
| TAG="${{ inputs.tag }}" | |
| else | |
| TAG=$(gh release view --repo "${{ github.repository }}" --json tagName -q .tagName) | |
| fi | |
| else | |
| TAG="${{ github.event.workflow_run.head_branch }}" | |
| fi | |
| VERSION="${TAG#v}" | |
| echo "tag=${TAG}" >> "$GITHUB_OUTPUT" | |
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Download Windows release artifact and compute SHA256 | |
| id: checksum | |
| run: | | |
| BASE_URL="https://github.com/${{ github.repository }}/releases/download/${{ steps.version.outputs.tag }}" | |
| FILE="longbridge-terminal-windows-amd64.zip" | |
| URL="${BASE_URL}/${FILE}" | |
| # Retry up to 5 times; release assets may not be immediately available | |
| for i in {1..5}; do | |
| if curl -fsSL --retry 3 -o "/tmp/${FILE}" "${URL}"; then | |
| break | |
| fi | |
| echo "Attempt $i failed for ${FILE}, retrying in 15s..." | |
| sleep 15 | |
| done | |
| SHA=$(sha256sum "/tmp/${FILE}" | awk '{print $1}') | |
| echo "windows_amd64_sha256=${SHA}" >> "$GITHUB_OUTPUT" | |
| echo "windows-amd64: ${SHA}" | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update scoop manifest | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| TAG: ${{ steps.version.outputs.tag }} | |
| SHA256: ${{ steps.checksum.outputs.windows_amd64_sha256 }} | |
| REPO: ${{ github.repository }} | |
| run: | | |
| set -euo pipefail | |
| GITHUB_URL="https://github.com/${REPO}/releases/download/${TAG}/longbridge-terminal-windows-amd64.zip" | |
| CDN_URL="https://assets.lbkrs.com/github/release/longbridge-terminal/v${VERSION}/longbridge-terminal-windows-amd64.zip" | |
| CDN_AUTOUPDATE_URL='https://assets.lbkrs.com/github/release/longbridge-terminal/v$version/longbridge-terminal-windows-amd64.zip' | |
| # Update .scoop/longbridge.json (GitHub URL, committed back to repo) | |
| jq \ | |
| --arg version "$VERSION" \ | |
| --arg url "$GITHUB_URL" \ | |
| --arg hash "$SHA256" \ | |
| '.version = $version | .architecture["64bit"].url = $url | .architecture["64bit"].hash = $hash' \ | |
| .scoop/longbridge.json > .scoop/longbridge.json.tmp | |
| mv .scoop/longbridge.json.tmp .scoop/longbridge.json | |
| # Generate longbridge.json for OSS (CDN URL for both current download and autoupdate template) | |
| jq \ | |
| --arg version "$VERSION" \ | |
| --arg url "$CDN_URL" \ | |
| --arg hash "$SHA256" \ | |
| --arg autourl "$CDN_AUTOUPDATE_URL" \ | |
| '.version = $version | |
| | .architecture["64bit"].url = $url | |
| | .architecture["64bit"].hash = $hash | |
| | .autoupdate.architecture["64bit"].url = $autourl' \ | |
| .scoop/longbridge.json > longbridge.json | |
| echo "--- Updated manifest (.scoop/longbridge.json) ---" | |
| cat .scoop/longbridge.json | |
| - name: Setup ossutil | |
| run: | | |
| wget -q https://github.com/aliyun/ossutil/releases/download/v1.7.17/ossutil-v1.7.17-linux-amd64.zip | |
| unzip -q ossutil-v1.7.17-linux-amd64.zip | |
| cp ./ossutil-v1.7.17-linux-amd64/ossutil . && chmod +x ./ossutil | |
| - name: Upload scoop manifest to OSS | |
| run: | | |
| set -euo pipefail | |
| ./ossutil cp longbridge.json \ | |
| oss://lb-assets/github/release/longbridge-terminal/longbridge.json \ | |
| -f \ | |
| -e oss-cn-hangzhou.aliyuncs.com \ | |
| -i ${{ secrets.FE_LB_ASSET_ACCESS_KEY_ID }} \ | |
| -k ${{ secrets.FE_LB_ASSET_ACCESS_KEY_SECRET }} \ | |
| --meta "Cache-Control:no-cache#Content-Type:application/json;charset=utf-8" | |
| - name: Commit and push | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| REPO: ${{ github.repository }} | |
| RUN_ID: ${{ github.run_id }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add .scoop/longbridge.json | |
| if git diff --cached --quiet; then | |
| echo "No changes detected — manifest is already up to date" | |
| exit 0 | |
| fi | |
| git commit -m "chore: bump scoop manifest to ${VERSION} | |
| Automated version bump triggered by https://github.com/${REPO}/actions/runs/${RUN_ID}" | |
| git push origin main |