-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (101 loc) · 3.6 KB
/
Copy pathr-package.yml
File metadata and controls
119 lines (101 loc) · 3.6 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Workflow derived from https://github.com/r-lib/actions
name: Build and Release R Package
on:
push:
branches: [ main, master ]
tags:
- 'v*'
release:
types: [created]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::devtools
any::roxygen2
any::pkgbuild
any::rcmdcheck
any::testthat
needs: workflow
- name: Document
run: roxygen2::roxygenise()
shell: Rscript {0}
- name: Check
run: |
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning")
shell: Rscript {0}
- name: Test
run: |
devtools::test()
shell: Rscript {0}
- name: Build package
id: build
run: |
pkg_file <- pkgbuild::build()
pkg_name <- basename(pkg_file)
# Get the full path of the file
full_path <- normalizePath(pkg_file)
cat("Full package path:", full_path, "\n")
# Write to GitHub output
cat("pkg_file=", full_path, "\n", file=Sys.getenv("GITHUB_OUTPUT"), sep="")
cat("pkg_name=", pkg_name, "\n", file=Sys.getenv("GITHUB_OUTPUT"), append=TRUE, sep="")
shell: Rscript {0}
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: r-package
path: ${{ steps.build.outputs.pkg_file }}
retention-days: 30
- name: Deploy to gh-pages
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "actions@github.com"
# Create or switch to gh-pages branch
git checkout -B gh-pages
# Clear the branch and copy the package
git rm -rf .
cp ${{ steps.build.outputs.pkg_file }} .
# Create an index.html with instructions
cat > index.html << EOF
<!DOCTYPE html>
<html>
<head>
<title>binaryClass R Package</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body { font-family: sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
pre { background: #f5f5f5; padding: 10px; border-radius: 5px; overflow-x: auto; }
</style>
</head>
<body>
<h1>binaryClass R Package</h1>
<p>Install the latest version with:</p>
<pre>
install.packages("https://codoom1.github.io/binaryClass/${{ steps.build.outputs.pkg_name }}", repos = NULL)
</pre>
<p>Released: $(date +'%Y-%m-%d')</p>
</body>
</html>
EOF
# Add both files and commit
git add ${{ steps.build.outputs.pkg_name }} index.html
git commit -m "Update package to latest version"
# Force push to gh-pages
git push --force origin gh-pages