From b654090a6e423cdd57c5d0ed93f3c9cc226d2f8b Mon Sep 17 00:00:00 2001 From: slhafzjw Date: Sun, 10 May 2026 23:18:07 +0800 Subject: [PATCH] feat(git): add latest buildable update workflow --- .github/workflows/update-latest-buildable.yml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/update-latest-buildable.yml diff --git a/.github/workflows/update-latest-buildable.yml b/.github/workflows/update-latest-buildable.yml new file mode 100644 index 00000000..596caba9 --- /dev/null +++ b/.github/workflows/update-latest-buildable.yml @@ -0,0 +1,70 @@ +name: Update latest buildable + +on: + workflow_dispatch: + inputs: + ref: + description: "Buildable ref, for example buildable/v0.5.0" + required: true + type: string + push: + tags: + - "buildable/*" + +permissions: + contents: write + +jobs: + update-latest-buildable: + runs-on: ubuntu-latest + + steps: + - name: Resolve buildable ref + id: buildable + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "ref=${{ inputs.ref }}" >> "$GITHUB_OUTPUT" + else + echo "ref=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" + fi + + - name: Checkout master + uses: actions/checkout@v4 + with: + ref: master + + - name: Update latestBuildable + run: | + python3 - <<'PY' + import json + from pathlib import Path + + ref = "${{ steps.buildable.outputs.ref }}" + index_path = Path("registry/index.json") + + index = json.loads(index_path.read_text(encoding="utf-8")) + + index["partner"]["latestBuildable"] = { + "url": "https://github.com/slhaf/Partner.git", + "ref": ref + } + + index_path.write_text( + json.dumps(index, ensure_ascii=False, indent=2) + "\n", + encoding="utf-8" + ) + PY + + - name: Commit registry update + run: | + if git diff --quiet registry/index.json; then + echo "No latestBuildable changes." + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + git add registry/index.json + git commit -m "chore(registry): update latest buildable to ${{ steps.buildable.outputs.ref }}" + git push \ No newline at end of file