Skip to content

Commit

Permalink
Fix automated release workflow (#98)
Browse files Browse the repository at this point in the history
* Fixed dependencies in `setup-r-dependencies` step.
* Added `rhub` email validation (using repository secrets).
* Fixed PR body by using `render-template` action.
* See
peter-evans/create-pull-request#2824 (comment)
* Improved checklists and appearance in `release-pr-body.md`.
* Added [usmap-bot](https://github.com/usmap-bot) as the PR and commit
author.
* Added commit signing.
  • Loading branch information
pdil authored Mar 18, 2024
2 parents 6e583e8 + 7e2606b commit 218a439
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
release_checklist <- function(version) {
release_checklist <- function(email, token, version) {
# Platform checks
devtools::check_rhub(interactive = FALSE)
rhub::validate_email(email, token)
devtools::check_rhub(email = email, interactive = FALSE)

devtools::check_win_devel()

# Reverse dependency checks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
`usmap v${{ inputs.version }}` release candidate
🚀 `usmap v{{ .version }}` release candidate

#### Pre-release checklist:
### 📝 Pre-release checklist
- [ ] Review automated changes
- [ ] Review rhub and win_devel checks (see maintainer email for results)
- [ ] Review reverse dependency checks
- [ ] Review check and test results
- [ ] Verify `DESCRIPTION` and `NEWS.md` are accurate
- [ ] Update `cran-comments.md` if necessary
- [ ] Update `NEWS` if necessary
- [ ] Run `devtools::release()` from this branch
- [ ] Perform necessary CRAN verification release steps (see maintainer email)
Wait for CRAN to publish package. If issues are reported, make changes in this PR and re-run `devtools::release()`.

#### Post-release checklist:
- [ ] `git tag v{{ $inputs.version }}`
⏳ Wait for CRAN to publish package. If changes are requested, commit fixes to this pull request and re-run `devtools::release()`.

### 📝 Post-release checklist
- [ ] `git tag v{{ .version }}`
- [ ] `git push --tags`
- [ ] Update `DESCRIPTION` and `NEWS.md` versions to `{{ $inputs.version }}.9000`
- [ ] Update `DESCRIPTION` and `NEWS.md` versions to `{{ .version }}.9000`
- [ ] Add release date of latest version to `NEWS.md`
- Example `Released Monday, February 31, 2020.`
- [ ] Commit changes with message `Prepare for next release`
- [ ] `usethis::use_github_release()`
- Merge this PR
- [ ] Run `usethis::use_github_release()` from this branch

✅ Merge this pull request when all post-release tasks are complete.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

on:
push:
branches: [main, master]
branches: master
pull_request:
branches: [main, master]
branches: master

name: R-CMD-check
name: check

jobs:
R-CMD-check:
check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})
Expand Down
41 changes: 33 additions & 8 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:
inputs:
version:
description: "The version number for new release, e.g. 1.0.2"
description: "Release version number (e.g. 1.0.2)"
required: true
type: string

Expand All @@ -24,16 +24,22 @@ jobs:
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::desc
any::devtools
any::revdepcheck
any::rhub
github::r-lib/revdepcheck
- name: Run release checks
env:
EMAIL: ${{ secrets.RHUB_EMAIL }}
TOKEN: ${{ secrets.RHUB_TOKEN }}
VERSION: ${{ inputs.version }}
run: |
source(".github/workflows/release-checklist.R")
release_checklist(Sys.getenv("VERSION"))
source(".github/workflow-resources/release-checklist.R")
release_checklist(
Sys.getenv("EMAIL"),
Sys.getenv("TOKEN"),
Sys.getenv("VERSION")
)
shell: Rscript {0}

- name: Update NEWS.md version
Expand All @@ -44,15 +50,34 @@ jobs:
include: "NEWS.md"
regex: false

- name: Import GPG signing key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

- name: Render PR body
id: pr-body
uses: chuhlomin/render-template@v1
with:
template: .github/workflow-resources/release-pr-body.md
vars: |
version: ${{ inputs.version }}
- name: Open pull request
id: open-pr
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.BOT_PAT }}
author: ${{ secrets.BOT_USER }}
committer: ${{ secrets.BOT_USER }}
commit-message: "[automated] Prepare for ${{ inputs.version }} release"
branch: release/${{ inputs.version }}
title: Release version ${{ inputs.version }}
body-path: .github/workflows/release-pr-body.md
body: ${{ steps.pr-body.outputs.result }}
reviewers: pdil
assignees: pdil
labels: release
delete-branch: true
draft: true
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ knitr::opts_chunk$set(
<!-- badges: start -->
[![CRAN](http://www.r-pkg.org/badges/version/usmap?color=blue)](https://cran.r-project.org/package=usmap)
[![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/usmap)](https://cran.r-project.org/package=usmap)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fpdil%2Fusmap%2Fbadge%3Fref%3Dmaster&style=popout&label=build)](https://actions-badge.atrox.dev/pdil/usmap/goto?ref=master)
[![check](https://github.com/pdil/usmap/actions/workflows/check/badge.svg)](https://github.com/pdil/usmap/actions/workflows/check.yaml)
[![codecov](https://codecov.io/gh/pdil/usmap/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pdil/usmap)
<!-- badges: end -->

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

[![CRAN](http://www.r-pkg.org/badges/version/usmap?color=blue)](https://cran.r-project.org/package=usmap)
[![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/usmap)](https://cran.r-project.org/package=usmap)
[![Build
Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fpdil%2Fusmap%2Fbadge%3Fref%3Dmaster&style=popout&label=build)](https://actions-badge.atrox.dev/pdil/usmap/goto?ref=master)
[![check](https://github.com/pdil/usmap/actions/workflows/check/badge.svg)](https://github.com/pdil/usmap/actions/workflows/check.yaml)
[![codecov](https://codecov.io/gh/pdil/usmap/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pdil/usmap)
<!-- badges: end -->

Expand Down

0 comments on commit 218a439

Please sign in to comment.