Skip to content

Commit

Permalink
Merge pull request #649 from DyfanJones/main
Browse files Browse the repository at this point in the history
pre-built binaries github action
  • Loading branch information
DyfanJones committed Jul 20, 2023
2 parents 2338a9b + 4c3f3fa commit 93fbe2e
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 7 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/packaging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Packaging

on:
schedule:
# At 12:00, on day 10 of the month, every 4 months
# Giving 10 days for paws regen to be approved
- cron: "0 12 10 */4 *"
workflow_dispatch:
inputs:
text_to_print:
description: "Manual re-build"

jobs:
binaries:
runs-on: ${{ matrix.config.runner }}
strategy:
fail-fast: false
matrix:

config:
- {r_version: 'release', os: macOS, version: cpu-intel, runner: macOS-latest}
- {r_version: 'release', os: ubuntu, runner: ubuntu-latest}
- {r_version: 'release', os: windows, runner: windows-latest}
- {r_version: 'oldrel-1', os: macOS, version: cpu-intel, runner: macOS-latest}
- {r_version: 'oldrel-1', os: windows, runner: windows-latest}

include:
- config: {os: ubuntu}
type: 'source'
r_install_tar: "tar"

- config: {os: windows}
type: 'win.binary'
r_install_tar: ""

- config: {os: macOS}
type: 'mac.binary'
r_install_tar: ""

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
R_INSTALL_TAR: ${{ matrix.r_install_tar }}

outputs:
pkg_version: ${{ steps.build.outputs.pkg_version }}

steps:

- uses: actions/checkout@v3

- name: Install R
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r_version }}

- uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: "2.17.1"

- name: Install System Dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev libssl-dev libxml2-dev libgit2-dev
sudo apt-get install -y libharfbuzz-dev libfribidi-dev
- name: Install Paws Dependencies
run: |
install.packages('pkgbuild')
shell: Rscript {0}

- name: Install Paws
run: |
install.packages('paws', repos = c(pawsr = 'https://paws-r.r-universe.dev', CRAN = 'https://cloud.r-project.org'))
shell: Rscript {0}

- name: Build binary package
id: build
run: |
lines <- readLines(file.path("cran", "paws", "DESCRIPTION"))
pkgs <- lines[grepl("paws\\.[a-z\\.]", lines, perl = T)]
pkgs <- file.path("cran", c("paws", trimws(gsub("\\([^)]*\\).*", "", pkgs))))
dest_path <- contrib.url("../binaries", type="binary")
dir.create(dest_path, recursive = TRUE)
for (pkg in pkgs) {
binary_path <- pkgbuild::build(path = pkg, binary = TRUE, dest_path=dest_path)
tools::write_PACKAGES(dest_path, type = "${{ matrix.type }}", addFiles = TRUE)
}
paws_version <- gsub("Version:[ ]+", "", readLines("cran/paws/DESCRIPTION", n = 3)[3])
cat("pkg_version=", paws_version, "\n", sep="", file = Sys.getenv("GITHUB_OUTPUT"))
shell: Rscript {0}

- name: 'upload-file'
run:
aws s3 sync "../binaries" "s3://paws-r-builds/packages/${{ steps.build.outputs.pkg_version }}/" --acl public-read --quiet

latest-binaries:
runs-on: ubuntu-latest
needs: binaries
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}

steps:
- name: Update Latest Binaries
run: |
aws s3 rm s3://paws-r-builds/packages/latest/ --recursive --quiet
aws s3 cp s3://paws-r-builds/packages/${{ needs.binaries.outputs.pkg_version }}/ s3://paws-r-builds/packages/latest/ --acl public-read --recursive --quiet
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ If you are using Linux, you will need to install the following OS packages:

Or install the development version from [r-universe](https://paws-r.r-universe.dev/ui#builds):
``` r
# Enable repository from paws-r
options(repos = c(
pawsr = 'https://paws-r.r-universe.dev',
CRAN = 'https://cloud.r-project.org')
)
install.packages('paws', repos = c(pawsr = 'https://paws-r.r-universe.dev', CRAN = 'https://cloud.r-project.org'))
```

As of `paws v0.3.0` it's possible to install paws from pre-build binaries from a CRAN like repository host on AWS S3. We currently provide
pre-built binaries for Linux as Mac and Windows binaries are supported on the CRAN. The main focus of this is to provide linux with some pre-built binaries so that the install time is spead up.

To get the latest pre-built binaries you can use the following:
```r
install.packages('paws', repos = c(pawsr = 'https://paws-r-builds.s3.amazonaws.com/packages/latest/', CRAN = 'https://cloud.r-project.org'))
```

# Download and install paws in R
install.packages('paws')
You can also get a specific version of paws by setting the version:
```r
install.packages('paws', repos = c(pawsr = 'https://paws-r-builds.s3.amazonaws.com/packages/0.3.0/', CRAN = 'https://cloud.r-project.org'))
```

## Credentials
Expand Down
11 changes: 11 additions & 0 deletions docker/rocker-r-base/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM rocker/r-base

RUN apt-get update
RUN apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev

RUN Rscript -e "install.packages('paws', repos = c(pawsr = 'https://paws-r-builds.s3.amazonaws.com/packages/latest/', CRAN = 'https://cloud.r-project.org'))"

CMD ["R"]
11 changes: 11 additions & 0 deletions docker/rocker-r2u/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM rocker/r2u:jammy

RUN apt-get update
RUN apt-get install -y --no-install-recommends \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev

RUN Rscript -e "install.packages('paws')"

CMD ["R"]

0 comments on commit 93fbe2e

Please sign in to comment.