This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/arrow-flight-sql-postgresql.git
The following commit(s) were added to refs/heads/main by this push:
new f62972c doc: Add support for devel/current/${version} switch (#84)
f62972c is described below
commit f62972c6296059778b8fe570871628c826c150d2
Author: Sutou Kouhei <[email protected]>
AuthorDate: Tue Aug 29 10:57:52 2023 +0900
doc: Add support for devel/current/${version} switch (#84)
Closes GH-83
---
.github/workflows/doc.yaml | 12 ++++++-
Rakefile | 78 ++++++++++++++++++++++++++++------------------
doc/source/conf.py | 2 +-
3 files changed, 59 insertions(+), 33 deletions(-)
diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml
index ac506ae..a7f960c 100644
--- a/.github/workflows/doc.yaml
+++ b/.github/workflows/doc.yaml
@@ -51,12 +51,22 @@ jobs:
with:
name: doc
path: doc/build
- - uses: actions/checkout@v3
+ - name: Prepare destination branch
+ uses: actions/checkout@v3
+ if: github.repository_owner == 'apache'
with:
fetch-depth: 0
path: site
persist-credentials: true
ref: asf-site
+ - name: Prepare destination branch for fork
+ if: github.repository_owner != 'apache'
+ run: |
+ mkdir -p site.repository
+ pushd site.repository
+ git init --initial-branch=asf-site
+ popd
+ git clone file://${PWD}/site.repository/.git site
- name: Publish
run: |
git config --global user.name 'github-actions[bot]'
diff --git a/Rakefile b/Rakefile
index e52b1ad..9dfa179 100644
--- a/Rakefile
+++ b/Rakefile
@@ -17,6 +17,8 @@
# specific language governing permissions and limitations
# under the License.
+require "tmpdir"
+
require_relative "helper"
version = Helper.detect_version
@@ -33,53 +35,67 @@ end
desc "Create #{archive_name}"
task :dist => archive_name
+def build_doc(output_directory, release: nil, for_publish: false)
+ env = {}
+ env["RELEASE"] = release if release
+ sh(env,
+ "sphinx-build",
+ "-b", "html",
+ "-j", "auto",
+ "doc/source",
+ output_directory)
+ if for_publish
+ rm_f("#{output_directory}/.buildinfo")
+ rm_rf("#{output_directory}/.doctrees")
+ end
+end
+
namespace :doc do
desc "Build HTML documentation"
task :html do
- sh("sphinx-build",
- "-b", "html",
- "-j", "auto",
- "doc/source",
- "doc/build")
+ build_doc("doc/build")
end
desc "Publish HTML documentation"
task :publish do
site = ENV["ASF_SITE"] || "site"
asf_yaml = File.expand_path(".asf.yaml")
- cleaned_doc = File.expand_path("doc/build.clean")
index_html = File.expand_path("doc/index.html")
- rm_rf(cleaned_doc)
- cp_r("doc/build", cleaned_doc)
- rm_f("#{cleaned_doc}/.buildinfo")
- rm_rf("#{cleaned_doc}/.doctrees")
-
- cd("site") do
- cp(asf_yaml, ".")
- sh("git", "add", "--force", ".asf.yaml")
- cp(index_html, ".")
- sh("git", "add", "--force", "index.html")
- if ENV["GITHUB_REF_TYPE"] == "tag"
+ Dir.mktmpdir do |tmp|
+ is_release = (ENV["GITHUB_REF_TYPE"] == "tag")
+ if is_release
new_version = ENV["GITHUB_REF_NAME"].gsub(/-rc\d+\z/, "")
+ new_doc = "#{tmp}/new"
+ build_doc(new_doc, for_publish: true)
+ current_doc = "#{tmp}/current"
+ build_doc(current_doc, release: "current", for_publish: true)
else
- new_version = "devel"
+ devel_doc = "#{tmp}/devel"
+ build_doc(devel_doc, release: "devel", for_publish: true)
end
- rm_rf(new_version)
- cp_r(cleaned_doc, new_version)
- sh("git", "add", "--force", new_version)
- unless new_version == "devel"
- rm_rf("current")
- cp_r(cleaned_doc, "current")
- sh("git", "add", "--force", "current")
+
+ add = lambda do |source, destination|
+ rm_rf(destination)
+ cp_r(source, destination)
+ sh("git", "add", "--force", destination)
end
- sh("git", "commit", "-m", "Publish", "--allow-empty")
- unless ENV["GITHUB_EVENT_NAME"] == "pull_request"
- dry_run = []
- if ENV["GITHUB_REF_TYPE"] != "tag" and ENV["GITHUB_REF_NAME"] != "main"
- dry_run << "--dry-run"
+
+ cd("site") do
+ add.call(asf_yaml, ".asf.yaml")
+ add.call(index_html, "index.html")
+ if is_release
+ add.call(new_doc, new_version)
+ add.call(current_doc, "current")
+ else
+ add.call(devel_doc, "devel")
+ end
+ sh("git", "commit", "-m", "Publish", "--allow-empty")
+ unless ENV["GITHUB_EVENT_NAME"] == "pull_request"
+ dry_run = []
+ dry_run << "--dry-run" unless ENV["GITHUB_REF_NAME"] == "main"
+ sh("git", "push", *dry_run, "origin", "asf-site:asf-site")
end
- sh("git", "push", *dry_run, "origin", "asf-site:asf-site")
end
end
end
diff --git a/doc/source/conf.py b/doc/source/conf.py
index 7154947..1985c44 100644
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -34,7 +34,7 @@ if not version:
meson_build_path = pathlib.Path(__file__).parent / '../../meson.build'
with open(meson_build_path) as meson_build:
version = re.search('version: \'(.+?)\'', meson_build.read())[1]
- release = version
+ release = os.environ.get('RELEASE', version)
# -- General configuration ---------------------------------------------------
#
https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration