Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/maintainers_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<module>` 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
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/javadoc-io.yml
Original file line number Diff line number Diff line change
@@ -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 }}
131 changes: 131 additions & 0 deletions scripts/refresh_javadoc_io.sh
Original file line number Diff line number Diff line change
@@ -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:^ *<module>\(.*\)</module> *$:\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>$version</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#*"<td>$version</td>"}
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#*<title>}
echo "${after_open%%</title>*}"
}

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/<module>"
exit 1
fi