From 5a2ada32a6abfc351bd13396135b7050ea916378 Mon Sep 17 00:00:00 2001 From: Wendy Raschke Date: Fri, 27 Oct 2023 11:25:45 -0500 Subject: [PATCH 1/7] Introduce GitHub Actions workflow YML, script for automating monthly release tasks --- .../workflows/update_files_for_release.yml | 61 +++++++++++++++++ update.sh | 67 +++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 .github/workflows/update_files_for_release.yml create mode 100644 update.sh diff --git a/.github/workflows/update_files_for_release.yml b/.github/workflows/update_files_for_release.yml new file mode 100644 index 000000000..11301294d --- /dev/null +++ b/.github/workflows/update_files_for_release.yml @@ -0,0 +1,61 @@ +# This workflow is triggered by manual inputs. + +name: Update files for the new release + +on: + workflow_dispatch: + inputs: + OLD_VERSION: + description: 'Enter old version' + # Show defaults as examples so user enters correct format. + default: '23.0.0.11' + required: true + type: string + NEW_VERSION: + description: 'Enter new version' + default: '23.0.0.12' + required: true + type: string + BUILD_LABEL: + description: 'Enter build label of release driver' + default: 'replace_with_gm_driver_label' + required: false + type: string + +jobs: + automate_release_updates: + runs-on: ubuntu-latest + + steps: + - name: Show useful information about the environment + run: echo "🔎 The name of the branch is ${{ github.ref }} and repository is ${{ github.repository }}." + + - name: Check out repository code + uses: actions/checkout@v4 + with: + ref: vNext + repository: wraschke/ci.docker + + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + + - name: Run update.sh script + run: bash ./update.sh ${{ inputs.OLD_VERSION }} ${{ inputs.NEW_VERSION }} ${{ inputs.BUILD_LABEL }} + + - name: Commit changes + uses: EndBug/add-and-commit@v9 + with: + default_author: github_actions + author_name: GitHub Actions + message: "Updates for the release of ${{ inputs.NEW_VERSION }}" + add: '${{ github.workspace }}/ga/*' + new_branch: "${{ inputs.NEW_VERSION }}-release" + push: true + tag_push: '--force' + + - name: Create Pull Request + run: | + gh pr create -B vNext -H "${{ inputs.NEW_VERSION }}-release" -r mbroz2 -r leochr --title "Updates for the release of ${{ inputs.NEW_VERSION }}" --body "Created by Github Actions" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file diff --git a/update.sh b/update.sh new file mode 100644 index 000000000..faf12f36e --- /dev/null +++ b/update.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +echo "Hello from the update.sh script!" +echo $(date) + +# Set variables to the positional parameters +OLD_VERSION=$1 +NEW_VERSION=$2 +BUILD_LABEL=$3 + +# See if NEW_VERSION and OLD_VERSION fit expected pattern. +if [[ $OLD_VERSION =~ 2[3-9]\.0\.0\.[0-9]+ && $NEW_VERSION =~ 2[3-9]\.0\.0\.[0-9]+ ]]; +then + echo "$OLD_VERSION and $NEW_VERSION matches expected version format." +else + echo "Either $OLD_VERSION or $NEW_VERSION does not fit expected version format." + exit 1; +fi + +# Get last digit of old version +OLD_SHORT_VERSION=${OLD_VERSION:7} + +echo "OLD_VERSION = $OLD_VERSION" +echo "NEW_VERSION = $NEW_VERSION" +echo "BUILD_LABEL = $BUILD_LABEL" +echo "OLD_SHORT_VERSION = $OLD_SHORT_VERSION" + +echo "Copying latest files to $NEW_VERSION" +cp -r ./ga/latest ./ga/$NEW_VERSION + +# Perform the substitutions in both latest and $NEW_VERSION directories. +for file in $(find ./ga/latest ./ga/$NEW_VERSION -name Dockerfile.*); do + echo "Processing $file"; + + sed -i'.bak' -e "s/$OLD_VERSION/$NEW_VERSION/" $file; + sed -i'.bak' -e "s/ARG LIBERTY_BUILD_LABEL=.*/ARG LIBERTY_BUILD_LABEL=$BUILD_LABEL/g" $file; + + # Do these substitutions only in $NEW_VERSION, not latest. + if [[ "$file" == "./ga/$NEW_VERSION/"* ]]; + then + sed -i'.bak' -e "s/ARG PARENT_IMAGE=icr.io\/appcafe\/websphere-liberty:kernel/ARG PARENT_IMAGE=icr.io\/appcafe\/websphere-liberty:$NEW_VERSION-kernel/g" $file; + sed -i'.bak' -e "s/FROM websphere-liberty:kernel/FROM websphere-liberty:$NEW_VERSION-kernel/g" $file; + fi + + # Clean up temp files + rm $file.bak + +done + +cp ./ga/$OLD_VERSION/images.txt ./ga/$NEW_VERSION/images.txt; +sed -i'.bak' -e "s/$OLD_VERSION/$NEW_VERSION/g" ./ga/$NEW_VERSION/images.txt; +rm ./ga/$NEW_VERSION/images.txt.bak; + +if [[ $(( $OLD_SHORT_VERSION % 3 )) -eq 0 ]] + then + : + else + rm -rf ./ga/$OLD_VERSION + fi + +# Finally, comment out "ga/*/*/resources/*" in .gitignore so +# newly created $NEW_VERSION/full/resources and $NEW_VERSION/kernel/resources +# directories can be committed and pushed. +sed -i'.bak' -e "s/ga\/\*\/\*\/resources\/\*/#ga\/\*\/\*\/resources\/\*/g" .gitignore +rm ./.gitignore.bak + +echo "Done performing file updates."; From 15b7ab83dd9d3c3c691b451d6523045718b2f5e0 Mon Sep 17 00:00:00 2001 From: Wendy Raschke Date: Fri, 27 Oct 2023 11:42:23 -0500 Subject: [PATCH 2/7] Correct repository name in checkout step --- .github/workflows/update_files_for_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_files_for_release.yml b/.github/workflows/update_files_for_release.yml index 11301294d..62f581138 100644 --- a/.github/workflows/update_files_for_release.yml +++ b/.github/workflows/update_files_for_release.yml @@ -34,7 +34,7 @@ jobs: uses: actions/checkout@v4 with: ref: vNext - repository: wraschke/ci.docker + repository: WASdev/ci.docker - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." From b61d0242bd44cc24e2881a5c5006e517cc860abb Mon Sep 17 00:00:00 2001 From: Wendy Raschke Date: Fri, 27 Oct 2023 11:55:44 -0500 Subject: [PATCH 3/7] Incorrect assumptions in debug and comments --- .github/workflows/update_files_for_release.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update_files_for_release.yml b/.github/workflows/update_files_for_release.yml index 62f581138..bec4eb8a0 100644 --- a/.github/workflows/update_files_for_release.yml +++ b/.github/workflows/update_files_for_release.yml @@ -27,17 +27,18 @@ jobs: runs-on: ubuntu-latest steps: - - name: Show useful information about the environment - run: echo "🔎 The name of the branch is ${{ github.ref }} and repository is ${{ github.repository }}." + - name: Show useful information about the workflow environment + run: echo "🔎 This workflow is running in branch ${{ github.ref }} and repository ${{ github.repository }}." - - name: Check out repository code + # This repository and branch to clone and checkout on runner + # could be different than repo and branch where workflow runs. + # Be aware of this nuance. + - name: Check out repository code to runner uses: actions/checkout@v4 with: ref: vNext repository: WASdev/ci.docker - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - name: Run update.sh script run: bash ./update.sh ${{ inputs.OLD_VERSION }} ${{ inputs.NEW_VERSION }} ${{ inputs.BUILD_LABEL }} From 0079e18d2a532d281f23292eece52f9099048bb7 Mon Sep 17 00:00:00 2001 From: Wendy Raschke Date: Fri, 27 Oct 2023 12:31:52 -0500 Subject: [PATCH 4/7] update.sh script does not need to be in main, should reside only in vNext --- update.sh | 67 ------------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 update.sh diff --git a/update.sh b/update.sh deleted file mode 100644 index faf12f36e..000000000 --- a/update.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -echo "Hello from the update.sh script!" -echo $(date) - -# Set variables to the positional parameters -OLD_VERSION=$1 -NEW_VERSION=$2 -BUILD_LABEL=$3 - -# See if NEW_VERSION and OLD_VERSION fit expected pattern. -if [[ $OLD_VERSION =~ 2[3-9]\.0\.0\.[0-9]+ && $NEW_VERSION =~ 2[3-9]\.0\.0\.[0-9]+ ]]; -then - echo "$OLD_VERSION and $NEW_VERSION matches expected version format." -else - echo "Either $OLD_VERSION or $NEW_VERSION does not fit expected version format." - exit 1; -fi - -# Get last digit of old version -OLD_SHORT_VERSION=${OLD_VERSION:7} - -echo "OLD_VERSION = $OLD_VERSION" -echo "NEW_VERSION = $NEW_VERSION" -echo "BUILD_LABEL = $BUILD_LABEL" -echo "OLD_SHORT_VERSION = $OLD_SHORT_VERSION" - -echo "Copying latest files to $NEW_VERSION" -cp -r ./ga/latest ./ga/$NEW_VERSION - -# Perform the substitutions in both latest and $NEW_VERSION directories. -for file in $(find ./ga/latest ./ga/$NEW_VERSION -name Dockerfile.*); do - echo "Processing $file"; - - sed -i'.bak' -e "s/$OLD_VERSION/$NEW_VERSION/" $file; - sed -i'.bak' -e "s/ARG LIBERTY_BUILD_LABEL=.*/ARG LIBERTY_BUILD_LABEL=$BUILD_LABEL/g" $file; - - # Do these substitutions only in $NEW_VERSION, not latest. - if [[ "$file" == "./ga/$NEW_VERSION/"* ]]; - then - sed -i'.bak' -e "s/ARG PARENT_IMAGE=icr.io\/appcafe\/websphere-liberty:kernel/ARG PARENT_IMAGE=icr.io\/appcafe\/websphere-liberty:$NEW_VERSION-kernel/g" $file; - sed -i'.bak' -e "s/FROM websphere-liberty:kernel/FROM websphere-liberty:$NEW_VERSION-kernel/g" $file; - fi - - # Clean up temp files - rm $file.bak - -done - -cp ./ga/$OLD_VERSION/images.txt ./ga/$NEW_VERSION/images.txt; -sed -i'.bak' -e "s/$OLD_VERSION/$NEW_VERSION/g" ./ga/$NEW_VERSION/images.txt; -rm ./ga/$NEW_VERSION/images.txt.bak; - -if [[ $(( $OLD_SHORT_VERSION % 3 )) -eq 0 ]] - then - : - else - rm -rf ./ga/$OLD_VERSION - fi - -# Finally, comment out "ga/*/*/resources/*" in .gitignore so -# newly created $NEW_VERSION/full/resources and $NEW_VERSION/kernel/resources -# directories can be committed and pushed. -sed -i'.bak' -e "s/ga\/\*\/\*\/resources\/\*/#ga\/\*\/\*\/resources\/\*/g" .gitignore -rm ./.gitignore.bak - -echo "Done performing file updates."; From e7dd1d03177d8953952e9901da248c38404101b0 Mon Sep 17 00:00:00 2001 From: Wendy Raschke Date: Mon, 30 Oct 2023 14:23:16 -0500 Subject: [PATCH 5/7] Commit Travis YML changes --- .github/workflows/update_files_for_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_files_for_release.yml b/.github/workflows/update_files_for_release.yml index bec4eb8a0..899c5d4dc 100644 --- a/.github/workflows/update_files_for_release.yml +++ b/.github/workflows/update_files_for_release.yml @@ -48,7 +48,7 @@ jobs: default_author: github_actions author_name: GitHub Actions message: "Updates for the release of ${{ inputs.NEW_VERSION }}" - add: '${{ github.workspace }}/ga/*' + add: '${{ github.workspace }}/ga/* ${{ github.workspace }}/.travis.yml' new_branch: "${{ inputs.NEW_VERSION }}-release" push: true tag_push: '--force' From bd4da82b316a570a77d645e08d4993f5f9bfc52c Mon Sep 17 00:00:00 2001 From: Wendy Raschke Date: Tue, 31 Oct 2023 10:52:04 -0500 Subject: [PATCH 6/7] Script rename and in subdir --- .github/workflows/update_files_for_release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_files_for_release.yml b/.github/workflows/update_files_for_release.yml index 899c5d4dc..5ac2f41eb 100644 --- a/.github/workflows/update_files_for_release.yml +++ b/.github/workflows/update_files_for_release.yml @@ -40,7 +40,7 @@ jobs: repository: WASdev/ci.docker - name: Run update.sh script - run: bash ./update.sh ${{ inputs.OLD_VERSION }} ${{ inputs.NEW_VERSION }} ${{ inputs.BUILD_LABEL }} + run: bash ./internal/create-new-release.sh ${{ inputs.OLD_VERSION }} ${{ inputs.NEW_VERSION }} ${{ inputs.BUILD_LABEL }} - name: Commit changes uses: EndBug/add-and-commit@v9 From 99ff36ef29700f3d6dcf2387a040b329b9a550e3 Mon Sep 17 00:00:00 2001 From: Wendy Raschke Date: Tue, 31 Oct 2023 12:09:41 -0500 Subject: [PATCH 7/7] Restore location structure of script and add .travis.yml --- .github/workflows/update_files_for_release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_files_for_release.yml b/.github/workflows/update_files_for_release.yml index 5ac2f41eb..60637515b 100644 --- a/.github/workflows/update_files_for_release.yml +++ b/.github/workflows/update_files_for_release.yml @@ -39,8 +39,8 @@ jobs: ref: vNext repository: WASdev/ci.docker - - name: Run update.sh script - run: bash ./internal/create-new-release.sh ${{ inputs.OLD_VERSION }} ${{ inputs.NEW_VERSION }} ${{ inputs.BUILD_LABEL }} + - name: Run update script + run: bash ./create-new-release.sh ${{ inputs.OLD_VERSION }} ${{ inputs.NEW_VERSION }} ${{ inputs.BUILD_LABEL }} - name: Commit changes uses: EndBug/add-and-commit@v9