diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e3f801..fa0d60f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Automatic URLs from `@__NBVIEWER_ROOT_URL__` and `@__BINDER_ROOT_URL__` now follow the + convention [used in Documenter.jl](https://github.com/JuliaDocs/Documenter.jl/pull/1298) + to ignore build version information. ([#162][github-162], [#163][github-163]) ## [2.9.0] - 2021-07-09 ### Added @@ -128,6 +132,8 @@ https://discourse.julialang.org/t/ann-literate-jl/10651 for release announcement [github-152]: https://github.com/fredrikekre/Literate.jl/pull/152 [github-156]: https://github.com/fredrikekre/Literate.jl/pull/156 [github-159]: https://github.com/fredrikekre/Literate.jl/pull/159 +[github-162]: https://github.com/fredrikekre/Literate.jl/issues/162 +[github-163]: https://github.com/fredrikekre/Literate.jl/pull/163 [Unreleased]: https://github.com/fredrikekre/Literate.jl/compare/v2.9.0...HEAD [2.9.0]: https://github.com/fredrikekre/Literate.jl/compare/v2.8.1...v2.9.0 diff --git a/src/Literate.jl b/src/Literate.jl index 496f5cb..efce6b8 100644 --- a/src/Literate.jl +++ b/src/Literate.jl @@ -263,11 +263,24 @@ function create_configuration(inputfile; user_config, user_kwargs, type=nothing) # Guess the package (or repository) root url edit_commit = "master" # TODO: Make this configurable like Documenter? deploy_branch = "gh-pages" # TODO: Make this configurable like Documenter? + # Strip build version from a tag (cf. JuliaDocs/Documenter.jl#1298, Literate.jl#162) + function version_tag_strip_build(tag) + m = match(Base.VERSION_REGEX, tag) + m === nothing && return tag + s0 = startswith(tag, 'v') ? "v" : "" + s1 = m[1] # major + s2 = m[2] === nothing ? "" : ".$(m[2])" # minor + s3 = m[3] === nothing ? "" : ".$(m[3])" # patch + s4 = m[5] === nothing ? "" : m[5] # pre-release (starting with -) + # m[7] is the build, which we want to discard + return "$s0$s1$s2$s3$s4" + end + if haskey(ENV, "HAS_JOSH_K_SEAL_OF_APPROVAL") # Travis CI repo_slug = get(ENV, "TRAVIS_REPO_SLUG", "unknown-repository") deploy_folder = if get(ENV, "TRAVIS_PULL_REQUEST", nothing) == "false" t = get(ENV, "TRAVIS_TAG", "") - isempty(t) ? get(user_config, "devurl", "dev") : t + isempty(t) ? get(user_config, "devurl", "dev") : version_tag_strip_build(t) else "previews/PR$(get(ENV, "TRAVIS_PULL_REQUEST", "##"))" end @@ -281,7 +294,7 @@ function create_configuration(inputfile; user_config, user_kwargs, type=nothing) repo_slug = get(ENV, "GITHUB_REPOSITORY", "unknown-repository") deploy_folder = if get(ENV, "GITHUB_EVENT_NAME", nothing) == "push" if (m = match(r"^refs\/tags\/(.*)$", get(ENV, "GITHUB_REF", ""))) !== nothing - String(m.captures[1]) + version_tag_strip_build(String(m.captures[1])) else get(user_config, "devurl", "dev") end diff --git a/test/runtests.jl b/test/runtests.jl index 79d74c3..be76f83 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -268,7 +268,7 @@ content = """ const TRAVIS_ENV = Dict( "TRAVIS_REPO_SLUG" => "fredrikekre/Literate.jl", - "TRAVIS_TAG" => "v1.2.0", + "TRAVIS_TAG" => "v1.2.0+docs", "TRAVIS_PULL_REQUEST" => "false", "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true", "TRAVIS_BUILD_DIR" => normpath(joinpath(@__DIR__, "..")), @@ -278,7 +278,7 @@ const ACTIONS_ENV = Dict( "GITHUB_ACTION" => "Build docs", "GITHUB_REPOSITORY" => "fredrikekre/Literate.jl", "GITHUB_EVENT_NAME" => "push", - "GITHUB_REF" => "refs/tags/v1.2.0", + "GITHUB_REF" => "refs/tags/v1.2.0+docs", "GITHUB_WORKSPACE" => normpath(joinpath(@__DIR__, "..")), (k => nothing for k in keys(TRAVIS_ENV))..., )