-
Notifications
You must be signed in to change notification settings - Fork 1
118 lines (99 loc) · 3.41 KB
/
drat--publish-package.yaml
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
on:
push:
branches: [master, main]
workflow_dispatch:
name: Publish package (drat)
jobs:
drat:
runs-on: ${{ matrix.config.os }}
name: "drat: ${{ matrix.config.os }} (R-${{ matrix.config.r }})"
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: 'oldrel'}
- {os: macOS-latest, r: 'release'}
- {os: macOS-latest, r: 'oldrel'}
# - {os: windows-latest, r: 'devel'}
# - {os: macOS-latest, r: 'devel'}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
SOURCE_REPO: ${{ github.repository }}
DEST_REPO: mokymai/download
TMP_DIR: tmp_dir
steps:
- uses: actions/checkout@v3
- name: Info
run: |
echo "GitHub actor: ${{ github.actor }}"
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
use-public-rspm: true
extra-repositories: "https://mokymai.github.io/download/"
- uses: r-lib/actions/setup-r-dependencies@v2
with:
cache-version: 1
extra-packages: |
roxygen2
devtools
drat
- name: Roxygenize
shell: Rscript {0}
run: roxygen2::roxygenize()
- name: Build source package
if: runner.os == 'Windows' && matrix.config.r == 'release'
shell: Rscript {0}
run: |
dir.create("check", showWarnings = FALSE)
devtools::build(path = "check")
- name: Build binary package
if: runner.os != 'Linux'
shell: Rscript {0}
run: |
dir.create("check", showWarnings = FALSE)
devtools::build(path = "check", binary = TRUE)
# The steps to include the built package in ${DEST_REPO}
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions | ${{ github.event.repository.name }}"
# git config --global url."https://${TOKEN}:[email protected]/".insteadOf "https://github.com/"
env:
TOKEN: ${{ secrets.DEPLOY_DRAT_TOKEN }}
- name: Git clone DEST_REPO
uses: actions/checkout@v3
with:
repository: ${{ env.DEST_REPO }} # 'mokymai/download'
ref: 'master'
path: "${{ env.TMP_DIR }}"
token: "${{ secrets.DEPLOY_DRAT_TOKEN }}"
- name: Drat -- insert
if: success()
shell: Rscript {0}
run: |
built_packages <-
list.files(
path = "check",
pattern = "[.]tar[.]gz$|[.]tgz$|[.]zip$",
full.names = TRUE
)
built_packages
for (i in seq_along(built_packages)) {
drat::insertPackages(
file = built_packages[i],
repodir = Sys.getenv("TMP_DIR"),
action = "archive"
)
}
- name: Drat -- commit and push
if: success()
shell: bash
run: |
cd "${TMP_DIR}" # move into the subdir, which is Git controlled
git add *
git add -f *.tar.gz
git commit -m "Update from ${SOURCE_REPO} ${{ runner.os }} R-${{ matrix.config.r }}" || echo "Nothing to commit"
git push origin master || echo "Nothing to commit"