Skip to content

Build package and update Code and website #262

Build package and update Code and website

Build package and update Code and website #262

name: Build package and update Code and website
on:
push:
branches:
- master
paths:
- build-package/**
- tests/**
- .github/workflows/build_package.yaml
- pkgdown/**
- DESCRIPTION
schedule:
- cron: "0 0 1 * *"
jobs:
build-package:
runs-on: ubuntu-22.04
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest"
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
DEBIAN_FRONTEND: "noninteractive"
QT_QPA_PLATFORM: "offscreen"
XDG_RUNTIME_DIR: "/tmp"
PYTHONPATH: "/usr/share/qgis/python/plugins:/usr/share/qgis/python"
SAGANGV: 0.0.7
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare Ubuntu for installing QGIS (common code)
run: |
# Prepare Ubuntu for installing QGIS (common code)
echo "::group::Dynamically set QGIS_PLUGINPATH environment var (available to next steps)"
mkdir ../extra_plugins
echo "QGIS_PLUGINPATH=$(pwd)/../extra_plugins" >> $GITHUB_ENV
echo "::endgroup::"
echo "::group::Install the QGIS Signing Key"
sudo wget -qO /etc/apt/keyrings/qgis-archive-keyring.gpg https://download.qgis.org/downloads/qgis-archive-keyring.gpg
echo "::endgroup::"
- name: Add repo to install latest QGIS release for Ubuntu
run: |
# Add repo to install latest QGIS release for Ubuntu (using an often outdated GRASS release from Ubuntu repo)
sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/qgis-archive-keyring.gpg] https://qgis.org/ubuntu `lsb_release -c -s` main" > /etc/apt/sources.list.d/qgis.list'
- name: Install QGIS
run: |
sudo apt-get update
sudo apt-get install -y qgis qgis-plugin-grass saga
wget -qO ../sagang_plugin.zip https://plugins.qgis.org/plugins/processing_saga_nextgen/version/$SAGANGV/download/
unzip -q ../sagang_plugin.zip -d ../extra_plugins
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
- name: Query R dependencies and report available versions
id: query
run: |
# Query R dependencies and report available versions
cat("::group::Install pak\n")
install.packages("pak", repos = "https://r-lib.github.io/p/pak/stable/")
cat("::endgroup::\n")
cat("::group::Create minimal data frame with pkg deps and store them\n")
depends <- rbind(
pak::pkg_deps("deps::.", dependencies = c("Config/Needs/check", "all")),
pak::pkg_deps("any::sessioninfo", dependencies = c("Config/Needs/check", "all")),
pak::pkg_deps("any::rcmdcheck", dependencies = c("Config/Needs/check", "all")),
pak::pkg_deps("any::remotes", dependencies = TRUE),
pak::pkg_deps("any::progress", dependencies = TRUE),
pak::pkg_deps("any::devtools", dependencies = TRUE)
)[, c("ref", "version")]
depends <- depends[depends$ref != "deps::.", ]
saveRDS(depends, ".github/depends.Rds")
cat("::endgroup::\n")
cat("::group::Store R-version\n")
cat("r-version=", sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
cat("::endgroup::\n")
cat("::group::Print results\n")
cat("R version:", sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), "\n")
print(as.data.frame(depends), row.names = FALSE)
cat("::endgroup::\n")
shell: Rscript {0}
- name: Install missing package dependencies
run: |
pak::pkg_install(c("deps::.", "any::sessioninfo", "any::rcmdcheck", "any::remotes", "any::progress", "any::devtools"), upgrade = FALSE, dependencies = c("Config/Needs/check", "all"))
shell: Rscript {0}
- name: Print QGIS info
run: |
print("Has QGIS:")
print(qgisprocess::has_qgis())
qgisprocess::qgis_configure()
# cat(qgisprocess::qgis_run("plugins")$stdout)
shell: Rscript {0}
- name: Delete all files in R
run: |
rm -f ./R/*.R
rm -f ./man/*.Rd
- name: Build Package functions in folder R and document them
run: source("./build-package/build_QGIS_functions.R")
shell: Rscript {0}
- name: Add QGIS version to description
run: source("./build-package/update_Description.R")
shell: Rscript {0}
- name: Package tests
run: |
devtools::test()
shell: Rscript {0}
- name: Check and install
run: |
devtools::build_vignettes()
devtools::check()
devtools::install()
shell: Rscript {0}
- name: Render README
run: source("./build-package/render_README.R")
shell: Rscript {0}
- uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "current update"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build package website
run: |
pkgdown::build_site()
shell: Rscript {0}
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
publish_dir: ./docs