1
1
using Base64
2
2
3
- const BUILDROOT = get (ENV , " BUILDROOT" , pwd ())
4
- const JULIA_SOURCE = get (ENV , " JULIA_SOURCE" , " $(BUILDROOT) /julia" )
5
- const JULIA_DOCS = get (ENV , " JULIA_DOCS" , " $(BUILDROOT) /docs.julialang.org" )
3
+ const BUILDROOT = get (ENV , " BUILDROOT" , pwd ())
4
+ const JULIA_SOURCE = get (ENV , " JULIA_SOURCE" , " $(BUILDROOT) /julia" )
5
+ const JULIA_DOCS = get (ENV , " JULIA_DOCS" , " $(BUILDROOT) /docs.julialang.org" )
6
+ const JULIA_DOCS_TMP = get (ENV , " JULIA_DOCS_TMP" , " $(BUILDROOT) /tmp" )
6
7
7
8
# download and extract binary for a given version, return path to executable
8
9
function download_release (v:: VersionNumber )
@@ -54,12 +55,14 @@ function makedocs(julia_exec)
54
55
end
55
56
end
56
57
57
- function copydocs (path)
58
+ function copydocs (file)
59
+ isdir (JULIA_DOCS_TMP) || mkpath (JULIA_DOCS_TMP)
58
60
output = " $(JULIA_SOURCE) /doc/_build/pdf/en"
61
+ destination = " $(JULIA_DOCS_TMP) /$(file) "
59
62
for f in readdir (output)
60
63
if startswith (f, " TheJuliaLanguage" ) && endswith (f, " .pdf" )
61
- cp (" $(output) /$(f) " , path ; force= true )
62
- @info " finished, output file copied to $(path ) ."
64
+ cp (" $(output) /$(f) " , destination ; force= true )
65
+ @info " finished, output file copied to $(destination ) ."
63
66
break
64
67
end
65
68
end
@@ -70,10 +73,9 @@ function build_release_pdf(v::VersionNumber)
70
73
@info " building PDF for Julia v$(x) .$(y) .$(z) ."
71
74
72
75
file = " julia-$(x) .$(y) .$(z) .pdf"
73
- path = " $(JULIA_DOCS) /$(file) "
74
76
75
77
# early return if file exists
76
- if isfile (path )
78
+ if isfile (" $(JULIA_DOCS) / $(file) " )
77
79
@info " PDF for Julia v$(x) .$(y) .$(z) already exists, skipping."
78
80
return
79
81
end
@@ -89,8 +91,8 @@ function build_release_pdf(v::VersionNumber)
89
91
# invoke makedocs
90
92
makedocs (julia_exec)
91
93
92
- # copy built PDF to JULIA_DOCS
93
- copydocs (path )
94
+ # copy built PDF to JULIA_DOCS_TMP
95
+ copydocs (file )
94
96
end
95
97
96
98
function build_nightly_pdf ()
@@ -100,9 +102,6 @@ function build_nightly_pdf()
100
102
_, _, v = split (readchomp (` $(julia_exec) --version` ))
101
103
@info " commit determined to $(commit) and version determined to $(v) ."
102
104
103
- file = " julia-$(v) .pdf"
104
- path = " $JULIA_DOCS /$file "
105
-
106
105
# checkout correct commit and clean repo
107
106
run (` git -C $(JULIA_SOURCE) checkout $(commit) ` )
108
107
run (` git -C $(JULIA_SOURCE) clean -fdx` )
@@ -111,7 +110,7 @@ function build_nightly_pdf()
111
110
makedocs (julia_exec)
112
111
113
112
# copy the built PDF to JULIA_DOCS
114
- copydocs (path )
113
+ copydocs (" julia- $(v) .pdf " )
115
114
end
116
115
117
116
# find all tags in the julia repo
@@ -139,12 +138,24 @@ function commit()
139
138
@info " skipping commit from pull requests."
140
139
return
141
140
end
141
+ if ! isdir (JULIA_DOCS_TMP)
142
+ @info " No new PDFs created, skipping commit."
143
+ return
144
+ end
142
145
@info " committing built PDF files."
143
146
144
147
# Make sure the repo is up to date
145
148
run (` git fetch origin` )
146
149
run (` git reset --hard origin/assets` )
147
150
151
+ # Copy file from JULIA_DOCS_TMP to JULIA_DOCS
152
+ for file in readdir (JULIA_DOCS_TMP)
153
+ endswith (file, " .pdf" ) || continue
154
+ from = joinpath (JULIA_DOCS_TMP, file)
155
+ @debug " Copying a PDF" file from pwd ()
156
+ cp (from, file; force = true )
157
+ end
158
+
148
159
mktemp () do keyfile, iokey; mktemp () do sshconfig, iossh
149
160
# Set up keyfile
150
161
write (iokey, base64decode (get (ENV , " DOCUMENTER_KEY_PDF" , " " )))
0 commit comments