diff --git a/.github/workflows/docker-openstudio.yml b/.github/workflows/docker-openstudio.yml index ceb18f5..f62b10c 100644 --- a/.github/workflows/docker-openstudio.yml +++ b/.github/workflows/docker-openstudio.yml @@ -1,6 +1,30 @@ name: openstudio-docker -on: [push, pull_request] +on: + push: + branches: + - master + - develop + pull_request: + workflow_dispatch: + inputs: + openstudio_version: + description: 'OpenStudio version (e.g. 3.10.0)' + required: true + default: '3.11.0' + openstudio_sha: + description: 'OpenStudio git SHA' + required: true + default: 'dee62bf9dd' + openstudio_version_ext: + description: 'Version extension (e.g. -rc1). Leave blank for a final release. Default: -rc1' + required: false + default: '' + apptainer_only: + description: 'Skip docker build/test and only build the .sif from an existing Docker Hub image' + required: false + default: 'false' + type: boolean # example of how to restrict to one branch and push event #on: @@ -17,14 +41,49 @@ env: OPENSTUDIO_VERSION: 3.11.0 OPENSTUDIO_SHA: dee62bf9dd OPENSTUDIO_VERSION_EXT: "-rc1" - OPENSTUDIO_DOWNLOAD_URL: "https://openstudio-ci-builds.s3-us-west-2.amazonaws.com/develop/OpenStudio-3.11.0-rc1%2Bdee62bf9dd-Ubuntu-22.04-x86_64.deb" + OPENSTUDIO_DOWNLOAD_URL: "https://openstudio-ci-builds.s3-us-west-2.amazonaws.com/develop/OpenStudio-3.11.0-rc1%2Bdee62bf9dd-Ubuntu-24.04-x86_64.deb" permissions: contents: read jobs: + setup: + runs-on: ubuntu-24.04 + outputs: + openstudio_version: ${{ steps.resolve.outputs.openstudio_version }} + openstudio_sha: ${{ steps.resolve.outputs.openstudio_sha }} + openstudio_version_ext: ${{ steps.resolve.outputs.openstudio_version_ext }} + steps: + - name: Resolve version + id: resolve + shell: bash + run: | + # Start from workflow-level defaults + VERSION="${OPENSTUDIO_VERSION}" + SHA="${OPENSTUDIO_SHA}" + EXT="${OPENSTUDIO_VERSION_EXT}" + + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + # Override version/sha if provided (they are required inputs so always non-empty) + VERSION="${{ inputs.openstudio_version }}" + SHA="${{ inputs.openstudio_sha }}" + # Unconditionally assign ext — empty string IS a valid value (final release) + # Do NOT use || here: "" || "-rc1" evaluates to "-rc1" in GHA expressions + EXT="${{ inputs.openstudio_version_ext }}" + fi + + echo "openstudio_version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "openstudio_sha=${SHA}" >> "$GITHUB_OUTPUT" + echo "openstudio_version_ext=${EXT}" >> "$GITHUB_OUTPUT" + echo "Resolved: OpenStudio ${VERSION}${EXT} (${SHA})" + docker: + needs: setup runs-on: ubuntu-24.04 + env: + OPENSTUDIO_VERSION: ${{ needs.setup.outputs.openstudio_version }} + OPENSTUDIO_SHA: ${{ needs.setup.outputs.openstudio_sha }} + OPENSTUDIO_VERSION_EXT: ${{ needs.setup.outputs.openstudio_version_ext }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -32,6 +91,7 @@ jobs: python-version: '3.12.x' - name: test and build + if: ${{ github.event.inputs.apptainer_only != 'true' }} shell: bash run: | set -euo pipefail @@ -56,8 +116,12 @@ jobs: apptainer: runs-on: ubuntu-24.04 - needs: docker - if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/custom_branch_name' }} + needs: [setup, docker] + if: ${{ github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/custom_branch_name' }} + env: + OPENSTUDIO_VERSION: ${{ needs.setup.outputs.openstudio_version }} + OPENSTUDIO_SHA: ${{ needs.setup.outputs.openstudio_sha }} + OPENSTUDIO_VERSION_EXT: ${{ needs.setup.outputs.openstudio_version_ext }} permissions: contents: read id-token: write diff --git a/.github/workflows/manual_installer_test.yml b/.github/workflows/manual_installer_test.yml index 459a093..c648b8d 100644 --- a/.github/workflows/manual_installer_test.yml +++ b/.github/workflows/manual_installer_test.yml @@ -6,7 +6,7 @@ on: os_installer_link: description: 'The Link where to download the LINUX OpenStudio SDK Installer (.DEB)' required: true - default: 'https://github.com/NREL/OpenStudio/releases/download/v3.4.0/OpenStudio-3.4.0+4bd816f785-Ubuntu-20.04.deb' + default: 'https://github.com/NREL/OpenStudio/releases/download/v3.4.0/OpenStudio-3.4.0+4bd816f785-Ubuntu-24.04.deb' os_version: description: 'OS version (e.g. 3.4.0). Must match .deb installer' required: true @@ -14,7 +14,7 @@ on: description: 'OS version extension (e.g. -alpha). Must match .deb installer' required: false docker_image_tag: - description: 'Docker image tag. Tag name will be prefixed with "dev-" unless tag = "develop"' + description: 'Docker image tag. If tag is "develop", it will be "develop". If tag matches a version pattern (e.g. 3.11.0-rc3), it will be used as-is. Otherwise, tag will be prefixed with "dev-".' required: true env: diff --git a/Dockerfile b/Dockerfile index a753137..fcc555e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.04 AS base +FROM ubuntu:24.04 AS base LABEL maintainer="Nicholas Long nicholas.long@nrel.gov" @@ -34,9 +34,9 @@ RUN apt-get update && apt-get install -y \ && if [ -z "${OPENSTUDIO_DOWNLOAD_URL}" ]; then \ ESC_VERSION=$(echo "${OPENSTUDIO_VERSION}${OPENSTUDIO_VERSION_EXT}" | sed 's/+/%2B/g'); \ if [ -n "${OPENSTUDIO_SHA}" ]; then \ - OPENSTUDIO_DOWNLOAD_URL="https://openstudio-ci-builds.s3.amazonaws.com/develop/OpenStudio-${ESC_VERSION}%2B${OPENSTUDIO_SHA}-Ubuntu-22.04-x86_64.deb"; \ + OPENSTUDIO_DOWNLOAD_URL="https://openstudio-ci-builds.s3.amazonaws.com/develop/OpenStudio-${ESC_VERSION}%2B${OPENSTUDIO_SHA}-Ubuntu-24.04-x86_64.deb"; \ else \ - OPENSTUDIO_DOWNLOAD_URL="https://openstudio-ci-builds.s3.amazonaws.com/develop/OpenStudio-${ESC_VERSION}-Ubuntu-22.04-x86_64.deb"; \ + OPENSTUDIO_DOWNLOAD_URL="https://openstudio-ci-builds.s3.amazonaws.com/develop/OpenStudio-${ESC_VERSION}-Ubuntu-24.04-x86_64.deb"; \ fi; \ fi \ && echo "OpenStudio Package Download URL is ${OPENSTUDIO_DOWNLOAD_URL}" \ diff --git a/deploy_docker.sh b/deploy_docker.sh index 8490e1a..37342d0 100755 --- a/deploy_docker.sh +++ b/deploy_docker.sh @@ -23,6 +23,8 @@ fi if [ ! -z "${DOCKER_MANUAL_IMAGE_TAG}" ]; then if [ "${DOCKER_MANUAL_IMAGE_TAG}" == "develop" ]; then IMAGETAG="develop" + elif [[ "${DOCKER_MANUAL_IMAGE_TAG}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then + IMAGETAG="${DOCKER_MANUAL_IMAGE_TAG}" else IMAGETAG="dev-${DOCKER_MANUAL_IMAGE_TAG}" fi