Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 111 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ on:
push:
branches:
- main
tags:
- 'v*' # Trigger on version tags
pull_request:
branches:
- main
Expand All @@ -11,6 +13,11 @@ on:
# run testing on the first of each month 5am ET / 9am UTC
- cron: '0 9 1 * *'

# Set minimal permissions for all jobs (read-only)
permissions:
contents: read
actions: read

jobs:
R-build:
strategy:
Expand All @@ -20,16 +27,15 @@ jobs:
os: [ 'macos-15-intel', 'ubuntu-latest', 'windows-latest']
runs-on: ${{ matrix.os }}
name: ${{ matrix.R }} ${{ matrix.os }} build
env:
R_LIBS: ${{ github.workspace }}/Rlibs

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup R
uses: r-lib/actions/setup-r@v2

- name: Setup R (also sets the R_LIBS_USER environment variable)
uses: r-lib/actions/setup-r@a51a8012b0aab7c32ef9d19bf54da93f3254335e # v2.12.0
with:
r-version: ${{ matrix.R }}
- name: System Dependencies
Expand All @@ -41,7 +47,6 @@ jobs:
- name: Configuration Information
shell: bash
run: |
mkdir -p "$R_LIBS"
cmake --version
if [[ "$RUNNER_OS" == "Windows" ]]; then
ls -d /c/rtools* 2>/dev/null || echo "No rtools found in /c/"
Expand All @@ -55,11 +60,109 @@ jobs:
- name: Install R packages
shell: bash
run: |
R -e "install.packages(c('remotes'), lib=Sys.getenv('R_LIBS'), repos='https://cloud.r-project.org/')"
R -e "install.packages(c('remotes'), lib=Sys.getenv('R_LIBS_USER'), repos='https://cloud.r-project.org/')"
- name: Build and test
shell: bash
env:
ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS: 2
run: |
R -e "Sys.setenv(MAKEJ=2); remotes::install_git(c('.'), lib=Sys.getenv('R_LIBS'))"
R -e "Sys.setenv(MAKEJ=2); remotes::install_git(c('.'), lib=Sys.getenv('R_LIBS_USER'))"
R -e "library(SimpleITK); Version()"
- name: Create binary package from installed package
Comment thread
blowekamp marked this conversation as resolved.
id: create_package
shell: bash
run: |
# Get the R version for naming
R_VERSION_SHORT=$(echo "${{ matrix.R }}" | cut -d'.' -f1,2)

# Get package version from DESCRIPTION
PKG_VERSION=$(Rscript -e "cat(read.dcf(file.path(Sys.getenv('R_LIBS_USER'), 'SimpleITK', 'DESCRIPTION'), 'Version')[1])")

# Create output directory for artifacts
mkdir -p artifacts

# Create binary package archive from installed package (no recompilation)
cd "${R_LIBS_USER}"
if [[ "$RUNNER_OS" == "macOS" ]]; then
PKG_NAME="SimpleITK_${PKG_VERSION}_R${R_VERSION_SHORT}_macos-x86_64.tgz"
tar czf "${GITHUB_WORKSPACE}/artifacts/${PKG_NAME}" SimpleITK
elif [[ "$RUNNER_OS" == "Linux" ]]; then
PKG_NAME="SimpleITK_${PKG_VERSION}_R${R_VERSION_SHORT}_linux-x86_64.tar.gz"
tar czf "${GITHUB_WORKSPACE}/artifacts/${PKG_NAME}" SimpleITK
elif [[ "$RUNNER_OS" == "Windows" ]]; then
PKG_NAME="SimpleITK_${PKG_VERSION}_R${R_VERSION_SHORT}_windows-x86_64.zip"
7z a -tzip "${GITHUB_WORKSPACE}/artifacts/${PKG_NAME}" SimpleITK
fi

cd "${GITHUB_WORKSPACE}"
ls -lh artifacts/

# Export PKG_NAME as output for use in upload step
echo "pkg_name=${PKG_NAME}" >> $GITHUB_OUTPUT
- name: Upload binary package
Comment thread
blowekamp marked this conversation as resolved.
if: steps.create_package.outcome == 'success'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ steps.create_package.outputs.pkg_name }}
path: artifacts/*
retention-days: 30

create-release:
name: Create GitHub Draft Release
# Only run this job for tag pushes after the R-build job completes
# successfully.
if: startsWith(github.ref, 'refs/tags/v')
needs: R-build
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1

- name: Verify tag matches SITK_TARGET
id: verify_tag
run: |
SITK_TARGET=$(grep '^SITK_TARGET:' DESCRIPTION | awk '{print $2}')
TAG_NAME="${{ github.ref_name }}"
if [ "${TAG_NAME}" != "${SITK_TARGET}" ]; then
echo "Tag ${TAG_NAME} does not match SITK_TARGET ${SITK_TARGET}"
echo "Skipping draft release creation."
echo "draft_release=false" >> $GITHUB_OUTPUT
else
echo "draft_release=true" >> $GITHUB_OUTPUT
fi

- name: Download all artifacts
if: steps.verify_tag.outputs.draft_release == 'true'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: release-artifacts
pattern: SimpleITK_*
merge-multiple: true

- name: Display downloaded artifacts
if: steps.verify_tag.outputs.draft_release == 'true'
run: |
echo "Downloaded artifacts:"
ls -lhR release-artifacts/

# This action automatically creates the release if it doesn't exist,
# or updates it if it does.
- name: Create or Update Draft Release
if: steps.verify_tag.outputs.draft_release == 'true'
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
env:
Comment thread
blowekamp marked this conversation as resolved.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
draft: true
name: SimpleITK ${{ github.ref_name }} R Package Release
body: |
Please review and test the packages before publishing this release.
Then remove the "Draft" status to make it public and delete this message.
files: |
release-artifacts/*
fail_on_unmatched_files: true
57 changes: 57 additions & 0 deletions .github/workflows/update_gh_cran.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Update CRAN Repository

on:
release:
types: [published]

permissions:
contents: write

concurrency:
group: update-cran-repository
cancel-in-progress: false

jobs:
update-repo:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Set up R
uses: r-lib/actions/setup-r@a51a8012b0aab7c32ef9d19bf54da93f3254335e # v2.12.0

- name: Download Release Assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mkdir -p temp_packages
gh release download ${{ github.event.release.tag_name }} --dir temp_packages

- name: Route Assets and Build PACKAGES Files
shell: bash
run: |
# Run the R script and always do the cleanup of the temp_packages directory,
# step returns the exit code from the R script.
(
Rscript update_cran_repo.R \
--packages-dir temp_packages \
--docs-dir docs \
--repo-url https://github.com/${{ github.repository }} \
--tag ${{ github.event.release.tag_name }}
status=$?
rm -rf temp_packages
exit $status
)

- name: Commit and Push Changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add docs/
if ! git diff --cached --quiet; then
git commit -m "Update CRAN repository index for release ${{ github.event.release.tag_name }}"
git push
fi
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Authors@R: c(person("Richard", "Beare", role = c("aut", "cre"),
email = "blowekamp@mail.nih.gov"),
person("Ziv", "Yaniv", role="aut",
email = "zivyaniv@nih.gov"))
Author: Richard Beare, Bradley Lowekamp, Ziv Yaniv plus loads of others
Author: Richard Beare, Bradley Lowekamp, Ziv Yaniv, The Insight Software Consortium and the ITK user and developer communities.
Depends: R (>= 4.0)
Imports: methods,
desc
Expand Down
5 changes: 5 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ mkdir -p SITK
mkdir -p Build &&
cd Build &&
cmake \
-D "CMAKE_CXX_FLAGS:STRING=-fvisibility=hidden -fvisibility-inlines-hidden ${CFLAGS}" \
-D "CMAKE_C_FLAGS:STRING=-fvisibility=hidden ${CFLAGS}" \
-DITK_C_OPTIMIZATION_FLAGS:STRING="" \
-DITK_CXX_OPTIMIZATION_FLAGS:STRING="" \
-DWRAP_DEFAULT=OFF\
-DWRAP_R=ON \
-DSimpleITK_BUILD_DISTRIBUTE=ON \
-DSimpleITK_BUILD_STRIP:BOOL=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=MinSizeRel \
Expand Down
5 changes: 5 additions & 0 deletions configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ export MAKEJ

# Configure with Unix Makefiles (Rtools toolchain)
cmake -G "Unix Makefiles" \
-D "CMAKE_CXX_FLAGS:STRING=-fvisibility=hidden -fvisibility-inlines-hidden ${CFLAGS}" \
-D "CMAKE_C_FLAGS:STRING=-fvisibility=hidden ${CFLAGS}" \
-DITK_C_OPTIMIZATION_FLAGS:STRING="" \
-DITK_CXX_OPTIMIZATION_FLAGS:STRING="" \
-DWRAP_DEFAULT=OFF \
-DWRAP_R=ON \
-DSimpleITK_BUILD_DISTRIBUTE=ON \
-DSimpleITK_BUILD_STRIP:BOOL=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
-DITK_SKIP_PATH_LENGTH_CHECK=ON \
Expand Down
Empty file added docs/.gitkeep
Empty file.
Loading
Loading