Skip to content

v0.2.5

v0.2.5 #80

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"