-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (49 loc) · 1.68 KB
/
update-citation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Update Citation Files
on:
push:
paths:
- "DESCRIPTION"
workflow_dispatch:
jobs:
update-citation:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up R
uses: r-lib/actions/setup-r@v2
- name: Install dependencies
run: |
Rscript -e 'install.packages(c("usethis", "cffr", "desc"))'
- name: Update inst/CITATION
run: |
Rscript -e '
library(desc);
# Read package metadata
package_title <- desc::desc_get("Title")
authors <- desc::desc_get("Authors@R")
version <- desc::desc_get("Version")
url <- desc::desc_get("URL")
year <- format(Sys.Date(), "%Y") # Get current year
# Generate citation content dynamically
citation_text <- sprintf("citHeader(\"To cite this package, use:\")\n\n
bibentry(\n
bibtype = \"Manual\",\n
title = \"%s\",\n
author = %s,\n
year = \"%s\",\n
note = \"R package version %s\",\n
url = \"%s\"
)", package_title, authors, year, version, url)
# Write the updated citation file
writeLines(citation_text, "inst/CITATION")'
- name: Update CITATION.cff
run: |
Rscript -e 'cffr::cff_write()'
- name: Commit and Push if Changed
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add inst/CITATION CITATION.cff
git commit -m "Auto-update citation files" || echo "No changes to commit"
git push