From a491b72300b140504523b2f41a0b6ff415228cb1 Mon Sep 17 00:00:00 2001 From: William Bergamin Date: Wed, 2 Dec 2026 11:35:07 -0500 Subject: [PATCH] ci: upload each release to javadoc.io so latest stays current javadoc.io no longer auto-indexes new Maven Central versions; latest only moves when a version is synced and uploaded from its versions page. A new workflow runs on release (or by hand with a version) and does that for every published module once Maven Central lists the version. Co-Authored-By: Claude --- .github/maintainers_guide.md | 1 + .github/workflows/javadoc-io.yml | 30 +++++++ scripts/refresh_javadoc_io.sh | 131 +++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+) create mode 100644 .github/workflows/javadoc-io.yml create mode 100755 scripts/refresh_javadoc_io.sh diff --git a/.github/maintainers_guide.md b/.github/maintainers_guide.md index d9df1c107..68563543f 100644 --- a/.github/maintainers_guide.md +++ b/.github/maintainers_guide.md @@ -134,6 +134,7 @@ These `-SNAPSHOT` versions are intended to be overwritten. This enables develope * [Look at previous releases](https://github.com/slackapi/java-slack-sdk/releases) and follow their layouts * If the signing key changed, announce the new fingerprint in the release notes * (Slack Internal) Publishing the GitHub Release runs the notify job in the [release workflow](./workflows/release.yml), which posts the release internally. Check that the announcement appears. +* Publishing the GitHub Release also runs the [javadoc.io workflow](./workflows/javadoc-io.yml), which uploads the new version so https://javadoc.io/doc/com.slack.api/bolt/latest points at it. If it fails, open `https://javadoc.io/versions/com.slack.api/` for each failed module, click "Sync from Maven", select the version, and click "Upload selected" * (Slack Internal) Tweet? Not necessary for patch updates, might be needed for minor updates, definitely needed for major updates. Include a link to the GitHub Release(s). * Anticipate the next version as a SNAPSHOT diff --git a/.github/workflows/javadoc-io.yml b/.github/workflows/javadoc-io.yml new file mode 100644 index 000000000..b502a848c --- /dev/null +++ b/.github/workflows/javadoc-io.yml @@ -0,0 +1,30 @@ +name: Refresh javadoc.io + +on: + release: + types: + - published + workflow_dispatch: + inputs: + version: + description: "Released version to upload to javadoc.io (e.g., 1.56.0)" + required: true + +jobs: + refresh: + name: Refresh javadoc.io + if: github.repository == 'slackapi/java-slack-sdk' && (github.event_name == 'workflow_dispatch' || !github.event.release.prerelease) + runs-on: ubuntu-latest + timeout-minutes: 90 + permissions: + contents: read + steps: + - name: Checkout the repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Upload the release to javadoc.io + run: ./scripts/refresh_javadoc_io.sh "${VERSION#v}" + env: + VERSION: ${{ inputs.version || github.event.release.tag_name }} diff --git a/scripts/refresh_javadoc_io.sh b/scripts/refresh_javadoc_io.sh new file mode 100755 index 000000000..a128b4a57 --- /dev/null +++ b/scripts/refresh_javadoc_io.sh @@ -0,0 +1,131 @@ +#!/bin/bash +set -uo pipefail + +version=${1:-} +if [[ "$version" == "" ]]; then + echo "Give a released version to refresh on javadoc.io (e.g., 1.56.0)" + exit 1 +fi + +group_id="com.slack.api" +central_url="https://repo1.maven.org/maven2/com/slack/api" +javadoc_io_url="https://javadoc.io" +poll_seconds=60 +central_deadline=$((SECONDS + 3600)) +sync_attempts=5 + +cookies=$(mktemp) +trap 'rm -f "$cookies"' EXIT + +published_modules() { + sed -n 's:^ *\(.*\) *$:\1:p' "$(dirname "$0")/../pom.xml" | grep -v -- '-examples$' +} + +is_on_central() { + local metadata + metadata=$(curl -fsS "$central_url/$1/maven-metadata.xml") || return 1 + [[ "$metadata" == *"$version"* ]] +} + +wait_for_central() { + until is_on_central "$1"; do + if ((SECONDS >= central_deadline)); then + return 1 + fi + sleep "$poll_seconds" + done +} + +versions_page() { + curl -fsS -b "$cookies" -c "$cookies" "$javadoc_io_url/versions/$group_id/$1" +} + +csrf_token() { + local after_name=${1#*name=\"csrfToken\" value=\"} + echo "${after_name%%\"*}" +} + +version_status() { + local page=$1 + local after_row=${page#*"$version"} + if [[ "$after_row" == "$page" ]]; then + return + fi + local after_title=${after_row#*title=\"} + echo "${after_title%%\"*}" +} + +submit() { + local module=$1 action=$2 token=$3 + shift 3 + curl -fsS -o /dev/null -b "$cookies" -c "$cookies" \ + --data-urlencode "csrfToken=$token" "$@" \ + "$javadoc_io_url/versions/$group_id/$module/$action" +} + +current_status() { + local page + page=$(versions_page "$1") || return 1 + version_status "$page" +} + +sync_from_central() { + local module=$1 page status attempt + for ((attempt = 1; attempt <= sync_attempts; attempt++)); do + page=$(versions_page "$module") || return 1 + submit "$module" sync "$(csrf_token "$page")" || return 1 + status=$(current_status "$module") || return 1 + if [[ "$status" != "" ]]; then + echo "$status" + return + fi + sleep "$poll_seconds" + done + return 1 +} + +upload() { + local module=$1 page + page=$(versions_page "$module") || return 1 + submit "$module" upload "$(csrf_token "$page")" --data-urlencode "versionId=$version" || return 1 + current_status "$module" +} + +refresh() { + local module=$1 status + wait_for_central "$module" || { echo "$version is not on Maven Central"; return 1; } + status=$(current_status "$module") || { echo "javadoc.io versions page is unreachable"; return 1; } + if [[ "$status" == "" ]]; then + status=$(sync_from_central "$module") || { echo "javadoc.io did not discover $version"; return 1; } + fi + if [[ "$status" == "DISCOVERED" ]]; then + status=$(upload "$module") || { echo "javadoc.io upload request failed"; return 1; } + fi + if [[ "$status" == "DISCOVERED" ]]; then + echo "javadoc.io did not accept the upload" + return 1 + fi + echo "$status" +} + +latest_title() { + local page + page=$(curl -fsSL "$javadoc_io_url/doc/$group_id/$1/latest/index.html") || return + local after_open=${page#*} + echo "${after_open%%*}" +} + +failures=0 +for module in $(published_modules); do + if result=$(refresh "$module"); then + echo "ok $module: $result, latest is \"$(latest_title "$module")\"" + else + echo "failed $module: $result" + failures=$((failures + 1)) + fi +done + +if ((failures > 0)); then + echo "$failures module(s) failed; upload $version by hand at $javadoc_io_url/versions/$group_id/" + exit 1 +fi