-
Notifications
You must be signed in to change notification settings - Fork 54
311 lines (263 loc) Β· 12.2 KB
/
cran-submission.yml
File metadata and controls
311 lines (263 loc) Β· 12.2 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
name: Submit to CRAN (Stage 3)
on:
workflow_dispatch:
inputs:
confirmation:
description: 'Type CONFIRM to submit to CRAN'
required: true
type: string
skip-remote-check:
description: 'Skip remote check validation (not recommended)'
required: false
type: boolean
default: false
release:
types: [prereleased]
jobs:
validate-prerequisites:
runs-on: ubuntu-latest
name: Validate prerequisites
outputs:
can-submit: ${{ steps.validate.outputs.can-submit }}
validation-message: ${{ steps.validate.outputs.message }}
steps:
- uses: actions/checkout@v4
- name: Validate submission prerequisites
id: validate
uses: actions/github-script@v7
with:
script: |
const skipRemoteCheck = '${{ github.event.inputs.skip-remote-check }}' === 'true';
const isRelease = context.eventName === 'release';
const confirmation = '${{ github.event.inputs.confirmation }}';
let canSubmit = true;
let messages = [];
// Check confirmation for manual triggers
if (context.eventName === 'workflow_dispatch') {
if (confirmation !== 'CONFIRM') {
canSubmit = false;
messages.push('β Manual submission requires typing "CONFIRM"');
}
}
// Check for recent successful remote checks (unless skipped)
if (!skipRemoteCheck) {
try {
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['cran-remote-check', 'passed'],
state: 'closed',
per_page: 1,
sort: 'updated',
direction: 'desc'
});
if (issues.data.length === 0) {
canSubmit = false;
messages.push('β No successful remote checks found. Run Stage 2 first.');
} else {
const lastCheck = new Date(issues.data[0].updated_at);
const daysSince = (Date.now() - lastCheck.getTime()) / (1000 * 60 * 60 * 24);
if (daysSince > 7) {
messages.push('β οΈ Last successful remote check was ' + Math.round(daysSince) + ' days ago');
} else {
messages.push('β
Recent successful remote check found');
}
}
} catch (error) {
console.log('Could not check remote check status:', error.message);
messages.push('β οΈ Could not verify remote check status');
}
} else {
messages.push('β οΈ Skipping remote check validation (not recommended)');
}
// Check for recent successful pre-checks
try {
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['cran-pre-check', 'passed'],
state: 'closed',
per_page: 1,
sort: 'updated',
direction: 'desc'
});
if (issues.data.length > 0) {
messages.push('β
Recent successful pre-check found');
} else {
messages.push('β οΈ No recent successful pre-checks found');
}
} catch (error) {
console.log('Could not check pre-check status:', error.message);
}
const message = messages.join('\n');
core.setOutput('can-submit', canSubmit.toString());
core.setOutput('message', message);
console.log('Validation result:', canSubmit ? 'PASSED' : 'FAILED');
console.log('Messages:\n' + message);
submit-to-cran:
runs-on: ubuntu-latest
name: Submit package to CRAN
needs: validate-prerequisites
if: needs.validate-prerequisites.outputs.can-submit == 'true'
permissions:
contents: read
issues: write
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::rcmdcheck, any::devtools, any::desc
needs: check
- name: Final local check
run: |
echo "π Running final R CMD check before submission..."
Rscript -e "
result <- rcmdcheck::rcmdcheck(
args = c('--no-manual', '--as-cran'),
error_on = 'warning',
check_dir = 'check'
)
cat('β
Final check passed\n')
"
- name: Extract package info
id: pkg-info
run: |
# Extract package info using R and desc package to handle Authors@R
Rscript -e "
library(desc)
desc_obj <- desc::desc()
pkg_name <- desc_obj\$get('Package')
pkg_version <- desc_obj\$get('Version')
maintainer_info <- desc_obj\$get_maintainer()
cat('package-name=', pkg_name, '\\n', sep='', file=stdout())
cat('package-version=', pkg_version, '\\n', sep='', file=stdout())
cat('maintainer=', maintainer_info, '\\n', sep='', file=stdout())
" >> $GITHUB_OUTPUT
- name: Submit to CRAN
id: cran-submit
run: |
echo "π Submitting to CRAN..."
Rscript -e "
library(devtools)
library(desc)
# Read package info using desc package
desc_obj <- desc::desc()
pkg_name <- desc_obj\$get('Package')
pkg_version <- desc_obj\$get('Version')
maintainer_info <- desc_obj\$get_maintainer()
cat('π¦ Submitting', pkg_name, 'version', pkg_version, 'to CRAN\n')
cat('π€ Maintainer:', maintainer_info, '\n')
# Submit using devtools::submit_cran
tryCatch({
result <- devtools::submit_cran(
pkg = '.',
args = NULL
)
cat('β
CRAN submission successful!\n')
cat('Please check your email for confirmation.\n')
}, error = function(e) {
cat('β CRAN submission failed:', e\$message, '\n')
quit(status = 1)
})
"
echo "submission-status=success" >> $GITHUB_OUTPUT
echo "submission-time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT
- name: Create submission issue
uses: actions/github-script@v7
with:
script: |
const packageName = '${{ steps.pkg-info.outputs.package-name }}';
const packageVersion = '${{ steps.pkg-info.outputs.package-version }}';
const maintainer = '${{ steps.pkg-info.outputs.maintainer }}';
const submissionTime = '${{ steps.cran-submit.outputs.submission-time }}';
const validationMessage = '${{ needs.validate-prerequisites.outputs.validation-message }}';
const title = `π― CRAN Submission: ${packageName} v${packageVersion}`;
let body = `## β
CRAN Submission Successful\n\n`;
body += `**Package:** ${packageName}\n`;
body += `**Version:** ${packageVersion}\n`;
body += `**Maintainer:** ${maintainer}\n`;
body += `**Submission Time:** ${submissionTime}\n`;
body += `**Trigger:** ${context.eventName === 'release' ? 'Pre-release' : 'Manual'}\n\n`;
body += `### π Pre-submission Validation\n\n`;
body += `\`\`\`\n${validationMessage}\n\`\`\`\n\n`;
body += `### π§ Next Steps\n\n`;
body += `1. **Check your email** (${maintainer}) for CRAN confirmation\n`;
body += `2. **Reply to the confirmation email** to complete submission\n`;
body += `3. **Monitor CRAN incoming:** https://cran.r-project.org/incoming/\n`;
body += `4. **Track status:** https://r-hub.github.io/cransays/articles/dashboard.html\n\n`;
body += `### β° Timeline\n\n`;
body += `- **Confirmation email:** Usually within 15-30 minutes\n`;
body += `- **Initial review:** 1-5 business days\n`;
body += `- **Publication:** If accepted, within 24 hours\n\n`;
body += `### π What CRAN Checks\n\n`;
body += `- R CMD check results (we already validated this)\n`;
body += `- Package size and dependencies\n`;
body += `- Documentation completeness\n`;
body += `- Code quality and best practices\n`;
body += `- License compliance\n\n`;
body += `### π If Changes Are Requested\n\n`;
body += `- CRAN may request fixes before acceptance\n`;
body += `- Make the requested changes\n`;
body += `- Re-run the complete workflow (Stages 1-3)\n`;
body += `- Resubmit with version bump if required\n\n`;
body += `---\n*Automated submission via 3-stage CRAN workflow*`;
// Close existing submission issues
const existingIssues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['cran-submission'],
state: 'open'
});
for (const issue of existingIssues.data) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: 'closed'
});
}
// Create new submission issue
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['cran-submission', 'stage-3', 'submitted']
});
submission-failed:
runs-on: ubuntu-latest
needs: validate-prerequisites
if: needs.validate-prerequisites.outputs.can-submit == 'false'
steps:
- name: Create validation failure issue
uses: actions/github-script@v7
with:
script: |
const validationMessage = '${{ needs.validate-prerequisites.outputs.validation-message }}';
const title = 'β CRAN Submission Failed - Prerequisites Not Met';
let body = `## β CRAN Submission Blocked\n\n`;
body += `The CRAN submission was blocked because prerequisites were not met.\n\n`;
body += `### π Validation Results\n\n`;
body += `\`\`\`\n${validationMessage}\n\`\`\`\n\n`;
body += `### π§ How to Fix\n\n`;
body += `1. **If Stage 1 failed:** Run "CRAN Pre-Check" workflow and fix any issues\n`;
body += `2. **If Stage 2 failed:** Run "CRAN Remote Check" workflow and address warnings/errors\n`;
body += `3. **If manual confirmation missing:** Use "CONFIRM" as the confirmation input\n\n`;
body += `### π Complete Workflow\n\n`;
body += `Follow the 3-stage process:\n`;
body += `1. **Stage 1:** CRAN Pre-Check (local validation)\n`;
body += `2. **Stage 2:** CRAN Remote Check (win-builder testing)\n`;
body += `3. **Stage 3:** Submit to CRAN (actual submission)\n\n`;
body += `Each stage must pass before proceeding to the next.\n`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['cran-submission', 'failed', 'prerequisites']
});