remove deployment from workflow #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build R packages repository | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| paths: | |
| - 'r-packages/**' | |
| - '.github/workflows/r-packages.yml' | |
| workflow_dispatch: | |
| jobs: | |
| build-source: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: 'release' | |
| - name: Install system dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install qpdf | |
| brew install --cask basictex | |
| - name: Install system dependencies (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| choco install rtools | |
| - name: Install system dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qpdf texinfo texlive-latex-base texlive-latex-extra \ | |
| libcurl4-openssl-dev libssl-dev libxml2-dev \ | |
| libudunits2-dev libgdal-dev libgeos-dev libproj-dev \ | |
| libfontconfig1-dev libharfbuzz-dev libfribidi-dev | |
| - name: Install R package dependencies | |
| run: | | |
| # First install dependencies that forecast needs | |
| install.packages(c( | |
| "timeDate", | |
| "zoo", | |
| "xts", | |
| "tseries", | |
| "fracdiff" | |
| ), repos="https://cloud.r-project.org", dependencies=TRUE) | |
| # Then try to install forecast | |
| install.packages("forecast", repos="https://cloud.r-project.org", dependencies=TRUE) | |
| # Finally install other needed packages | |
| install.packages(c( | |
| "miniCRAN", | |
| "remotes", | |
| "Rcpp", | |
| "httr", | |
| "memoise", | |
| "foreach", | |
| "snow", | |
| "ggplot2", | |
| "cclust", | |
| "randtoolbox", | |
| "dfoptim", | |
| "doSNOW", | |
| "scoringRules", | |
| "gridExtra", | |
| "reshape2", | |
| "VineCopula", | |
| "jsonlite", | |
| "skimr", | |
| "ranger", | |
| "glmnet", | |
| "xgboost", | |
| "e1071", | |
| "caret", | |
| "R6" | |
| ), repos="https://cloud.r-project.org", dependencies=TRUE) | |
| shell: Rscript {0} | |
| - name: Build source packages | |
| run: | | |
| # Create R script for building packages | |
| cat << 'EOF' > build_packages.R | |
| library(miniCRAN) | |
| # Define directories | |
| repo_dir <- "r-packages" | |
| # Create the repository directories | |
| dir.create(file.path(repo_dir, "src/contrib"), recursive = TRUE, showWarnings = FALSE) | |
| # List of R packages to build | |
| packages <- c( | |
| "ahead", | |
| "bcn", | |
| "crossvalidation", | |
| "ESGtoolkit", | |
| "learningmachine", | |
| "misc", | |
| "mlsauce_r" | |
| ) | |
| # Build and store package source tarballs | |
| message("\nBuilding packages...") | |
| for (pkg_name in packages) { | |
| message(paste("\nBuilding", pkg_name, "...")) | |
| pkg_dir <- file.path(".", pkg_name) | |
| if (dir.exists(pkg_dir)) { | |
| # Run R CMD build | |
| system(paste("R CMD build", pkg_dir)) | |
| # Find the created tarball | |
| pkg_file <- list.files(".", pattern = paste0(basename(pkg_name), ".*\\.tar\\.gz$"), full.names = TRUE) | |
| if (length(pkg_file) > 0) { | |
| # Move the package to the repository directory | |
| file.copy(pkg_file[1], file.path(repo_dir, "src/contrib"), overwrite = TRUE) | |
| file.remove(pkg_file[1]) # Clean up | |
| message(paste("Successfully built and copied:", pkg_name)) | |
| } | |
| } | |
| } | |
| # Create PACKAGES files | |
| tools::write_PACKAGES(file.path(repo_dir, "src/contrib"), type="source") | |
| EOF | |
| # Run the R script | |
| Rscript build_packages.R | |
| build-binaries: | |
| needs: build-source | |
| strategy: | |
| matrix: | |
| os: [windows-latest, macos-latest] | |
| include: | |
| - os: windows-latest | |
| platform: win.binary | |
| path: bin/windows/contrib/4.3 | |
| - os: macos-latest | |
| platform: mac.binary | |
| path: bin/macosx/contrib/4.3 | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: 'release' | |
| - name: Install system dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install qpdf | |
| brew install --cask basictex | |
| - name: Install system dependencies (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| choco install rtools | |
| - name: Install system dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y qpdf texinfo texlive-latex-base texlive-latex-extra | |
| - name: Install R package dependencies | |
| run: | | |
| packages <- c( | |
| "Rcpp", "memoise", "foreach", "snow", "forecast", | |
| "ggplot2", "tseries", "cclust", "randtoolbox", | |
| "dfoptim", "doSNOW", "scoringRules", "gridExtra", | |
| "reshape2", "VineCopula", "httr", "jsonlite", | |
| "skimr", "ranger", "glmnet", "xgboost", "e1071", | |
| "caret", "R6" | |
| ) | |
| install.packages(packages, repos="https://cloud.r-project.org", dependencies=TRUE) | |
| # Verify installation | |
| installed <- rownames(installed.packages()) | |
| missing <- packages[!packages %in% installed] | |
| if (length(missing) > 0) { | |
| stop("Missing packages: ", paste(missing, collapse=", ")) | |
| } | |
| shell: Rscript {0} | |
| - name: Build binary packages | |
| run: | | |
| mkdir -p r-packages/${{ matrix.path }} | |
| Get-ChildItem -Path "r-packages" -Directory | | |
| Where-Object { $_.Name -ne "src" -and $_.Name -ne "bin" } | | |
| ForEach-Object { | |
| $pkg = $_.FullName | |
| Start-Process -FilePath "R" -ArgumentList "CMD", "INSTALL", "--build", "$pkg", "--no-multiarch" -NoNewWindow -Wait | |
| } | |
| Move-Item -Path *.zip, *.tgz -Destination r-packages/${{ matrix.path }}/ -ErrorAction SilentlyContinue | |
| shell: pwsh | |
| - name: Create PACKAGES files | |
| run: | | |
| Rscript -e 'tools::write_PACKAGES("r-packages/${{ matrix.path }}", type="${{ matrix.platform }}")' | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: r-packages-${{ matrix.os }} | |
| path: r-packages | |
| finalize: | |
| needs: [build-source, build-binaries] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Merge repositories | |
| run: | | |
| mkdir -p r-packages | |
| cp -r artifacts/*/* r-packages/ | |
| # Add debug information | |
| echo "Contents of artifacts directory:" | |
| ls -R artifacts/ | |
| echo "Contents of r-packages directory:" | |
| ls -R r-packages/ | |
| - name: Commit and push changes | |
| run: | | |
| git config --global thierrymoudiki 'thierrymoudiki' | |
| git config --global [email protected] '[email protected]' | |
| git add r-packages/ | |
| git commit -m "Update R packages repository" || echo "No changes to commit" | |
| git push |