diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3781e65d0b9..2b517bc8050 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -11,6 +11,7 @@ env: jobs: docker_amd64: + if: github.repository == 'router-for-me/CLIProxyAPI' runs-on: ubuntu-latest steps: - name: Checkout @@ -49,6 +50,7 @@ jobs: ${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}-amd64 docker_arm64: + if: github.repository == 'router-for-me/CLIProxyAPI' runs-on: ubuntu-24.04-arm steps: - name: Checkout @@ -87,6 +89,7 @@ jobs: ${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}-arm64 docker_manifest: + if: github.repository == 'router-for-me/CLIProxyAPI' runs-on: ubuntu-latest needs: - docker_amd64 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b20684868a9..1ace3b1af5c 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -51,17 +51,27 @@ jobs: previous_tag="" if previous_tag_value="$(git describe --tags --abbrev=0 "${GITHUB_REF_NAME}^" 2>/dev/null)"; then previous_tag="$previous_tag_value" + fi + + if [[ -n "$previous_tag" ]]; then changelog_range="${previous_tag}..${GITHUB_REF_NAME}" + git log --reverse --pretty=format:'- %s (%h)' "$changelog_range" | + grep -Ev '^- (docs:|test:)' > "$changelog_entries_file" || true else - changelog_range="$GITHUB_REF_NAME" + # First release in this repository: the complete history exceeds the + # GitHub release body limit, so summarize the most recent commits. + git log --reverse -n 40 --pretty=format:'- %s (%h)' "$GITHUB_REF_NAME" | + grep -Ev '^- (docs:|test:)' > "$changelog_entries_file" || true fi - git log --reverse --pretty=format:'- %s (%h)' "$changelog_range" | - grep -Ev '^- (docs:|test:)' > "$changelog_entries_file" || true - - gh api "repos/${GH_REPO}/releases/generate-notes" \ - -f tag_name="$GITHUB_REF_NAME" \ - --jq .body > "$generated_notes_file" + if [[ -n "$previous_tag" ]]; then + gh api "repos/${GH_REPO}/releases/generate-notes" \ + -f tag_name="$GITHUB_REF_NAME" \ + -f previous_tag_name="$previous_tag" \ + --jq .body > "$generated_notes_file" + else + printf 'Initial release of %s.\n' "$GITHUB_REF_NAME" > "$generated_notes_file" + fi if [[ ! -s "$generated_notes_file" ]]; then if [[ -n "$previous_tag" ]]; then printf '**Full Changelog**: https://github.com/%s/compare/%s...%s\n' "$GH_REPO" "$previous_tag" "$GITHUB_REF_NAME" > "$generated_notes_file" @@ -85,6 +95,22 @@ jobs: cat "$changelog_notes_file" } > "$updated_notes_file" + # GitHub rejects release bodies above 125000 characters. Truncate on a + # UTF-8 boundary with headroom so the release is still created. + python3 - "$updated_notes_file" <<'PY' + import sys + + limit = 120000 + suffix = "\n\n_Release notes were truncated to fit the GitHub release body limit._\n" + target = sys.argv[1] + with open(target, "rb") as handle: + body = handle.read().decode("utf-8", "replace") + if len(body) > limit: + body = body[: limit - len(suffix)].rstrip() + suffix + with open(target, "w", encoding="utf-8", newline="\n") as handle: + handle.write(body) + PY + if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then gh release edit "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file "$updated_notes_file" else