From 5976f9cbba47593c115f39644b2badc40b26562f Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 29 Jul 2025 16:08:27 +0100 Subject: [PATCH 1/5] move release branch creation to GHA --- .github/workflows/create-release-branches.yml | 50 +++++++ release_scripts/Jenkinsfile_branches | 123 ------------------ release_scripts/branches.py | 7 - release_scripts/requirements.txt | 5 - 4 files changed, 50 insertions(+), 135 deletions(-) create mode 100644 .github/workflows/create-release-branches.yml delete mode 100644 release_scripts/Jenkinsfile_branches diff --git a/.github/workflows/create-release-branches.yml b/.github/workflows/create-release-branches.yml new file mode 100644 index 00000000..dae6724e --- /dev/null +++ b/.github/workflows/create-release-branches.yml @@ -0,0 +1,50 @@ +on: + workflow_dispatch: + inputs: + version: + description: 'The release version in X.x.m format e.g. 12.3.2' + required: true + type: string + remote: + description: 'Update submodules to latest version from remote. Defaults to false, appropriate for a normal release' + default: false + type: boolean + tag: + description: "Commit to branch release from. Defaults to 'HEAD', appropriate for a normal release. May need to set specific TAG here for patch release" + default: "HEAD" + type: string + create_epics_branches: + description: 'Create release branches for EPICS and submodules' + default: true + type: boolean + create_ibex_gui_branch: + description: 'Create release branch for IBEX GUI' + default: true + type: boolean + create_script_gen_branch: + description: 'Create release branch for the Script Generator' + default: true + type: boolean + create_uktena_branch: + description: 'Create release branch for Uktena Python distribution' + default: true + type: boolean + +jobs: + create_release_branches: + runs-on: ubuntu-latest + env: + VERSION: ${github.event.inputs.version} + REMOTE: ${github.event.inputs.remote} + TAG: ${github.event.inputs.tag} + EPICS: ${github.event.inputs.create_epics_branches} + IBEX_GUI: ${github.event.inputs.create_ibex_gui_branch} + SCRIPT_GENERATOR: ${github.event.inputs.create_script_gen_branch} + UKTENA: ${github.event.inputs.create_uktena_branch} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.11' + - run: python -m pip install -r release_scripts/requirements.txt + - run: python --version ${github.event.inputs.version} diff --git a/release_scripts/Jenkinsfile_branches b/release_scripts/Jenkinsfile_branches deleted file mode 100644 index 9f8a40c1..00000000 --- a/release_scripts/Jenkinsfile_branches +++ /dev/null @@ -1,123 +0,0 @@ -#!groovy - -pipeline { - - agent { - label { - label("sl7cloud") - } - } - - options { - buildDiscarder(logRotator(numToKeepStr:'5')) - disableConcurrentBuilds() - timestamps() - // as we "checkout scm" as a stage, we do not need to do it here too - skipDefaultCheckout(true) - office365ConnectorWebhooks([[ - name: "Office 365", - notifyBackToNormal: true, - startNotification: false, - notifyFailure: true, - notifySuccess: false, - notifyNotBuilt: false, - notifyAborted: false, - notifyRepeatedFailure: true, - notifyUnstable: true, - url: "${env.MSTEAMS_URL}" - ]] - ) - } - - stages { - - stage("Checkout") { - steps { - echo "Branch: ${env.BRANCH_NAME}" - checkout scm - } - } - - stage('Set params') { - steps { - script { - properties([ - parameters([ - string( - name: "VERSION", - description: "The release version in X.x.m format e.g. 12.3.2", - trim: true - ), - booleanParam( - name: "REMOTE", - description: "Update submodules to latest version from remote. Defaults to false, appropriate for a normal release", - defaultValue: false - ), - string( - name: "TAG", - description: "Commit to branch release from. Defaults to 'HEAD', appropriate for a normal release. May need to set specific TAG here for patch release.", - defaultValue: "HEAD", - trim: true - ), - booleanParam( - name: "EPICS", - description: "Create release branches for EPICS and submodules.", - defaultValue: true - ), - booleanParam( - name: "IBEX_GUI", - description: "Create release branch for IBEX GUI.", - defaultValue: true, - ), - booleanParam( - name: "SCRIPT_GENERATOR", - description: "Create release branch for the Script Generator.", - defaultValue: true - ), - booleanParam( - name: "UKTENA", - description: "Create release branch for Uktena Python distribution.", - defaultValue: true - ), - booleanParam( - name: "JSON_BOURNE", - description: "Create release branch for JSON_bourne.", - defaultValue: false - ) - ]) - ]) - } - } - } - - stage("Create release branches") { - steps { - sh """ - python3 -m pip install -r release_scripts/requirements.txt --user - python3 -u release_scripts/branches.py --version ${params.VERSION} - """ - } - } - - stage("Start release builds") { - steps { - script { - if (params.EPICS) { - build job: "EPICS_release", propagate: false, wait: false - build job: "EPICS_release32", propagate: false, wait: false - } - if (params.UKTENA) { - build job: "uktena_release_pipeline", propagate: false, wait: false - } - if (params.IBEX_GUI) { - build job: "ibex_gui_releases_pipeline", propagate: false, wait: false - } - if (params.SCRIPT_GENERATOR) { - build job: "scriptgenerator_release", propagate: false, wait: false - } - // currently no release job for JSON_Bourne but it is not deployed to instruments directly - } - } - } - } -} diff --git a/release_scripts/branches.py b/release_scripts/branches.py index 906e552e..d7f77499 100644 --- a/release_scripts/branches.py +++ b/release_scripts/branches.py @@ -12,13 +12,11 @@ EPICS_REPO_URL = "https://github.com/ISISComputingGroup/EPICS.git" IBEX_REPO_URL = "https://github.com/ISISComputingGroup/ibex_gui.git" UKTENA_URL = "https://github.com/ISISComputingGroup/uktena.git" -JSON_BOURNE_URL = "https://github.com/ISISComputingGroup/JSON_bourne.git" EPICS_DIR = "EPICS" IBEX_DIR = "IBEX" SCRIPT_GEN_DIR = "SCRIPT_GEN" UKTENA_DIR = "UKTENA" -JSON_BOURNE_DIR = "JSON_bourne" INSTETC_TEMPLATE_LOCAL_PATH = os.path.join( "INSTETC", "INSTETC-IOC-01App", "Db", "svn-revision.db.tmpl" @@ -266,8 +264,3 @@ def push(self, submodules: bool = False) -> None: uktena = ReleaseBranch() uktena.create(UKTENA_URL, UKTENA_DIR, f"Release_{args.version}") uktena.push() - - if os.getenv("JSON_BOURNE") == "true": - json_bourne = ReleaseBranch() - json_bourne.create(JSON_BOURNE_URL, JSON_BOURNE_DIR, f"Release_{args.version}") - json_bourne.push() diff --git a/release_scripts/requirements.txt b/release_scripts/requirements.txt index 05a50189..64b1adae 100644 --- a/release_scripts/requirements.txt +++ b/release_scripts/requirements.txt @@ -1,6 +1 @@ -# Used for Python on Linux Jenkins node. - -###### Requirements without Version Specifiers ###### GitPython - -###### Requirements with Version Specifiers ###### From e3f32404069bf0cd95cf3f7eba9a2a8f76331fae Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 29 Jul 2025 16:11:57 +0100 Subject: [PATCH 2/5] ruff format --- release_scripts/branches.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_scripts/branches.py b/release_scripts/branches.py index d7f77499..8eaf47bd 100644 --- a/release_scripts/branches.py +++ b/release_scripts/branches.py @@ -123,7 +123,7 @@ def create(self, url: str, dir: str, branch_name: str, submodules: bool = False) logging.info(f"Cloning '{url}' into '{dir}'.") self.repo = git.Repo.clone_from(url=url, to_path=dir) if branch_name in self.repo.references: - logging.error(f"Branch name '{branch_name}' " f"already exists for repo '{url}'.") + logging.error(f"Branch name '{branch_name}' already exists for repo '{url}'.") sys.exit(1) source = os.getenv("TAG") From baa2c7d7fb5674b2eba3d3b08446cad2cacd9cb9 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 29 Jul 2025 16:15:54 +0100 Subject: [PATCH 3/5] add jenkinsfile_branches back in in case we need it for release --- release_scripts/Jenkinsfile_branches | 123 +++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 release_scripts/Jenkinsfile_branches diff --git a/release_scripts/Jenkinsfile_branches b/release_scripts/Jenkinsfile_branches new file mode 100644 index 00000000..9f8a40c1 --- /dev/null +++ b/release_scripts/Jenkinsfile_branches @@ -0,0 +1,123 @@ +#!groovy + +pipeline { + + agent { + label { + label("sl7cloud") + } + } + + options { + buildDiscarder(logRotator(numToKeepStr:'5')) + disableConcurrentBuilds() + timestamps() + // as we "checkout scm" as a stage, we do not need to do it here too + skipDefaultCheckout(true) + office365ConnectorWebhooks([[ + name: "Office 365", + notifyBackToNormal: true, + startNotification: false, + notifyFailure: true, + notifySuccess: false, + notifyNotBuilt: false, + notifyAborted: false, + notifyRepeatedFailure: true, + notifyUnstable: true, + url: "${env.MSTEAMS_URL}" + ]] + ) + } + + stages { + + stage("Checkout") { + steps { + echo "Branch: ${env.BRANCH_NAME}" + checkout scm + } + } + + stage('Set params') { + steps { + script { + properties([ + parameters([ + string( + name: "VERSION", + description: "The release version in X.x.m format e.g. 12.3.2", + trim: true + ), + booleanParam( + name: "REMOTE", + description: "Update submodules to latest version from remote. Defaults to false, appropriate for a normal release", + defaultValue: false + ), + string( + name: "TAG", + description: "Commit to branch release from. Defaults to 'HEAD', appropriate for a normal release. May need to set specific TAG here for patch release.", + defaultValue: "HEAD", + trim: true + ), + booleanParam( + name: "EPICS", + description: "Create release branches for EPICS and submodules.", + defaultValue: true + ), + booleanParam( + name: "IBEX_GUI", + description: "Create release branch for IBEX GUI.", + defaultValue: true, + ), + booleanParam( + name: "SCRIPT_GENERATOR", + description: "Create release branch for the Script Generator.", + defaultValue: true + ), + booleanParam( + name: "UKTENA", + description: "Create release branch for Uktena Python distribution.", + defaultValue: true + ), + booleanParam( + name: "JSON_BOURNE", + description: "Create release branch for JSON_bourne.", + defaultValue: false + ) + ]) + ]) + } + } + } + + stage("Create release branches") { + steps { + sh """ + python3 -m pip install -r release_scripts/requirements.txt --user + python3 -u release_scripts/branches.py --version ${params.VERSION} + """ + } + } + + stage("Start release builds") { + steps { + script { + if (params.EPICS) { + build job: "EPICS_release", propagate: false, wait: false + build job: "EPICS_release32", propagate: false, wait: false + } + if (params.UKTENA) { + build job: "uktena_release_pipeline", propagate: false, wait: false + } + if (params.IBEX_GUI) { + build job: "ibex_gui_releases_pipeline", propagate: false, wait: false + } + if (params.SCRIPT_GENERATOR) { + build job: "scriptgenerator_release", propagate: false, wait: false + } + // currently no release job for JSON_Bourne but it is not deployed to instruments directly + } + } + } + } +} From 238b2da8e129dfc1d0a2b78f5e70a061704aa6b5 Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 29 Jul 2025 16:19:13 +0100 Subject: [PATCH 4/5] add token --- .github/workflows/create-release-branches.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/create-release-branches.yml b/.github/workflows/create-release-branches.yml index dae6724e..cf1bb799 100644 --- a/.github/workflows/create-release-branches.yml +++ b/.github/workflows/create-release-branches.yml @@ -30,17 +30,19 @@ on: default: true type: boolean +env: + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} + VERSION: ${github.event.inputs.version} + REMOTE: ${github.event.inputs.remote} + TAG: ${github.event.inputs.tag} + EPICS: ${github.event.inputs.create_epics_branches} + IBEX_GUI: ${github.event.inputs.create_ibex_gui_branch} + SCRIPT_GENERATOR: ${github.event.inputs.create_script_gen_branch} + UKTENA: ${github.event.inputs.create_uktena_branch} + jobs: create_release_branches: runs-on: ubuntu-latest - env: - VERSION: ${github.event.inputs.version} - REMOTE: ${github.event.inputs.remote} - TAG: ${github.event.inputs.tag} - EPICS: ${github.event.inputs.create_epics_branches} - IBEX_GUI: ${github.event.inputs.create_ibex_gui_branch} - SCRIPT_GENERATOR: ${github.event.inputs.create_script_gen_branch} - UKTENA: ${github.event.inputs.create_uktena_branch} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 From 06977cd0857d2508f614a9a64748a9553589664c Mon Sep 17 00:00:00 2001 From: Jack Harper Date: Tue, 29 Jul 2025 16:22:04 +0100 Subject: [PATCH 5/5] use 3.12 --- .github/workflows/create-release-branches.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release-branches.yml b/.github/workflows/create-release-branches.yml index cf1bb799..2bea403f 100644 --- a/.github/workflows/create-release-branches.yml +++ b/.github/workflows/create-release-branches.yml @@ -47,6 +47,6 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: '3.12' - run: python -m pip install -r release_scripts/requirements.txt - run: python --version ${github.event.inputs.version}