You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Backport innovations from the future. Example of a useful opening move:
42
-
`git checkout main -- _pkgdown.yml .github/workflows/pkgdown.yaml`
43
-
44
-
Most likely candidates:
45
-
- `_pkgdown.yml`
46
-
- `.github/workflows/pkgdown.yaml`
47
-
- `Config/Needs/website: tidyverse/tidytemplate` in DESCRIPTION
48
-
- Any fixes to `README.Rmd` / `README.md` or released roxygen comments. Don't
49
-
forget to `devtools::build_readme()` or `devtools::document()`, in that
50
-
case.
51
-
52
-
These are the two main Git commands you'll need:
53
-
```
54
-
git checkout REF -- path/to/a/specific/file
55
-
git cherry-pick SHA
56
-
```
57
-
* Monitor your progress locally with `pkgdown::build_site()`.
58
-
* Push this branch, maybe using `usethis::pr_push()`. Don't bother opening
59
-
a pull request (the branch will still be created and pushed).
60
-
* Go to your package's GHA page, maybe using `usethis::browse_github_actions()`.
61
-
Select the pkgdown workflow. Click *Run workflow* and select the branch you
62
-
just pushed. If there's no dropdown menu for this, that means your pkgdown
63
-
workflow config is not current.
64
-
* Scrutinize your newly published **released** site and make sure things look
65
-
right.
66
-
* You can let this branch sit around for a while, in case you need to iterate
67
-
on this or if you'd like to backport more niceties before your next CRAN
68
-
release. Or you can delete immediately, if you're happy with the released
69
-
site.
17
+
This vignette shows you how to update the released version of your site to match the dev version of the site, so the first step is to ensure that the dev site looks the way that you want it.
18
+
19
+
## Process
20
+
21
+
If you're up to speed with the basic idea and just want some code to follow here it us.
22
+
Otherwise, read more below.
23
+
24
+
### Setup
25
+
26
+
First, make sure you're in the main branch, and you have the latest version:
27
+
28
+
```{r}
29
+
gert::git_branch_checkout("main")
30
+
gert::git_pull()
31
+
```
32
+
33
+
Next figure out the released version that we're updating:
34
+
35
+
```{r}
36
+
ver <- desc::desc_get_version()[1, 1:3]
37
+
```
38
+
39
+
We'll use this to create the branch that you'll work in:
Now you need to backport changes from the dev site into this branch.
48
+
Run this R code to generate the git code to pull changes for the most common locations:
49
+
50
+
```{r}
51
+
files <- c(
52
+
# overall site config
53
+
"_pkgdown.yml",
54
+
# the GHA that'll impenet
55
+
".github/workflows/pkgdown.yaml",
56
+
# readme and vignettes
57
+
"README.md", "vignettes",
58
+
# logo and favicon
59
+
"man/figures/", "pkgdown/",
60
+
# Author metadata and Config/Needs/Website
61
+
"DESCRIPTION"
62
+
)
63
+
64
+
glue::glue("git checkout v{ver} -- {files}")
65
+
```
66
+
67
+
If you update the description, you'll also need undo the change to the `Version`:
68
+
69
+
```{r}
70
+
desc::desc_set_version(ver)
71
+
```
72
+
73
+
Now build the site locally and check that it looks as you expect:
74
+
75
+
```{r}
76
+
pkgdown::build_site()
77
+
```
78
+
79
+
### Publish
80
+
81
+
Now you need to publish the site.
82
+
First push your branch to GitHub:
83
+
84
+
```{r}
85
+
usethis:::git_push_first()
86
+
```
87
+
88
+
Then trigger the pkgdown workflow:
89
+
90
+
1. Going to your package's GHA page, e.g. with `usethis::browse_github_actions())`.
91
+
2. Select the pkgdown workflow.
92
+
3. Click *Run workflow* and select the branch you just pushed.
93
+
94
+
If there's no dropdown menu for this, that means your pkgdown workflow config is not current.
70
95
71
96
## Context
72
97
73
98
Before we talk about **how** to update a released site, we first establish **why** you might need to do this.
74
-
What is a released site? What other kind of pkgdown site could you have?
99
+
What is a released site?
100
+
What other kind of pkgdown site could you have?
75
101
Why does updating a released site take special effort?
76
102
77
103
### Automatic development mode
@@ -91,7 +117,7 @@ This directs pkgdown to "generate different sites for the development and releas
91
117
92
118
The readr package demonstrates what happens in automatic development mode:
93
119
94
-
[readr.tidyverse.org](https://readr.tidyverse.org) documents the released version, i.e. what `install.packages()` would deliver.
120
+
[readr.tidyverse.org](https://readr.tidyverse.org) documents the released version, i.e. what `install.packages()` would deliver.\
95
121
[readr.tidyverse.org/dev/](https://readr.tidyverse.org/dev/) documents the dev version, i.e. what you'd get by installing from GitHub.
96
122
97
123
In this mode, `pkgdown::build_site()`, consults DESCRIPTION to learn the package's version number.
@@ -108,7 +134,7 @@ Now that we've established the meaning of a released (vs dev) site, we have to c
108
134
Many people use `usethis::use_pkgdown_github_pages()` to do basic pkgdown setup and configure a GitHub Actions (GHA) workflow to automatically render and publish the site to GitHub Pages.
109
135
Here's an overview of what this function does:
110
136
111
-
```
137
+
```
112
138
usethis::use_pkgdown_github_pages() =
113
139
use_pkgdown() +
114
140
use_github_pages() +
@@ -148,96 +174,92 @@ on:
148
174
<snip, snip>
149
175
```
150
176
151
-
We build and deploy for pushes to `main` (or `master`).
152
-
We build for pull requests against `main` (or `master`).
177
+
We build and deploy for pushes to `main` (or `master`).\
178
+
We build for pull requests against `main` (or `master`).\
153
179
But we don't deploy for pull requests.
154
180
155
-
We build and deploy when we publish a GitHub release.
156
-
By convention, we assume that a GitHub release coincides with a CRAN release.
157
-
**This is the primary mechanism for building the released pkgdown site.**
181
+
We build and deploy when we publish a GitHub release.\
182
+
By convention, we assume that a GitHub release coincides with a CRAN release.\
183
+
**This is the primary mechanism for building the released pkgdown site.**
158
184
159
185
`pkgdown::build_site_github_pages()`consults the version in DESCRIPTION to detect whether it's building from a released version or a dev version.
160
186
That determines the `dest_dir`, e.g. `docs/` for released and `docs/dev/` for dev.
161
-
For a package in automatic development mode, this means that almost all of your pushes trigger an update to the dev site.
187
+
For a package in automatic development mode, this means that almost all of your pushes trigger an update to the dev site.
162
188
The released site is only updated when you push a state with a non-development version number or when you publish a GitHub release.
163
189
164
190
So how do you tweak things about the released site *in between* releases?
165
191
166
-
That brings us to `workflow_dispatch:`. (Yes that dangling colon is correct.)
192
+
That brings us to `workflow_dispatch:`.
193
+
(Yes that dangling colon is correct.)
167
194
168
-
The inclusion of `workflow_dispatch` as a trigger means the pkgdown workflow can be run on demand, either manually from the browser or via the GitHub REST API.
169
-
We're going to show how to update a released site from a GitHub branch or tag, using the browser method.
195
+
The inclusion of `workflow_dispatch` as a trigger means the pkgdown workflow can be run on demand, either manually from the browser or via the GitHub REST API. We're going to show how to update a released site from a GitHub branch or tag, using the browser method.
170
196
In the future, we might build some tooling around the API method.
171
197
172
198
Places to learn more about triggering GHA workflows:
Now you should backport innovations from the future that you would like to retroactively apply to your released site.
206
231
207
232
Files you must update:
208
233
209
-
* `.github/workflows/pkgdown.yaml`
210
-
* `_pkgdown.yml`
211
-
* `Config/Needs/website` field of DESCRIPTION (And, probably, only this field!
212
-
In particular, do not mess with the version number.)
234
+
- `.github/workflows/pkgdown.yaml`
235
+
- `_pkgdown.yml`
236
+
- `Config/Needs/website`field of DESCRIPTION (And, probably, only this field! In particular, do not mess with the version number.)
213
237
214
-
Other likely candidates:
238
+
Other likely candidates:
215
239
216
-
* `README.Rmd` + `README.md`, e.g., if you've updated badges.
217
-
* Any documentation fixes that **apply to the released version**. This is the
218
-
only reason to touch anything below `R/` and even then it should only affect
219
-
roxygen comments. Don't forget to `document()` if you do this!
220
-
* Any new vignettes or articles that apply to the released version.
240
+
- `README.Rmd`+ `README.md`, e.g., if you've updated badges.
241
+
- Any documentation fixes that **apply to the released version**. This is the only reason to touch anything below `R/` and even then it should only affect roxygen comments. Don't forget to `document()` if you do this!
242
+
- Any new vignettes or articles that apply to the released version.
221
243
222
244
Here are some tips on backporting specific changes into this branch.
223
245
If you are lucky, there are specific commits in your default branch that contain all the necessary changes.
224
246
In that case, we can cherry pick such a commit by its SHA:
225
247
226
-
```
248
+
```
227
249
git cherry-pick SHA
228
250
```
229
251
230
252
If that doesn't cover everything, for each file you want to update, identify a Git reference (meaning: a SHA, tag, or branch) where the file is in the desired state.
231
253
Checkout that specific file path from that specific ref:
232
254
233
-
```
255
+
```
234
256
git checkout REF -- path/to/the/file
235
257
```
236
-
258
+
237
259
For example, readr recently gained a new vignette that applies to the released version of readr, i.e. it does not document any dev-only features or functions.
238
260
Here's how to introduce the new vignette from HEAD of `main` into the current branch:
239
261
240
-
```
262
+
```
241
263
git checkout main -- vignettes/column-types.Rmd
242
264
```
243
265
@@ -249,14 +271,13 @@ Now we will use the `workflow_dispatch` GHA trigger.
249
271
Go to the Actions page of your repo, maybe via `usethis::browse_github_actions()`.
250
272
Click on the `pkgdown` workflow.
251
273
252
-
You should see "This workflow has a workflow_dispatch event trigger."
274
+
You should see "This workflow has a workflow_dispatch event trigger."\
253
275
(If you don't, that means you didn't do one of the pre-requisites, which is to update to `v2` of the pkgdown workflow.)
254
-
276
+
255
277
See the "Run workflow" button?
256
-
CLICK IT.
257
-
In the "Use workflow from" dropdown menu, select the branch you've just made and pushed.
278
+
CLICK IT. In the "Use workflow from" dropdown menu, select the branch you've just made and pushed.
258
279
This should kick off a pkgdown build-and-deploy and, specifically, it should cause updates to the **released** site.
259
-
280
+
260
281
You can keep this branch around for a while, in case you didn't get everything right the first time or if more things crop up that you'd like backport to the released site, before your next CRAN release.
0 commit comments