From 9946bf946dcb2acf92f5a279e72bfbed22de9022 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 21 Oct 2021 08:12:04 +0100 Subject: [PATCH 1/5] Automate updating weekly version --- .github/workflows/updatecli.yaml | 36 +++++++++++++++++++++++++++ updatecli/updatecli.d/weekly-apply.sh | 24 ++++++++++++++++++ updatecli/updatecli.d/weekly.yaml | 19 ++++++++++++++ updatecli/values.yaml | 5 ++++ 4 files changed, 84 insertions(+) create mode 100644 .github/workflows/updatecli.yaml create mode 100755 updatecli/updatecli.d/weekly-apply.sh create mode 100644 updatecli/updatecli.d/weekly.yaml create mode 100644 updatecli/values.yaml diff --git a/.github/workflows/updatecli.yaml b/.github/workflows/updatecli.yaml new file mode 100644 index 000000000..3a005e2ce --- /dev/null +++ b/.github/workflows/updatecli.yaml @@ -0,0 +1,36 @@ +name: updatecli + +on: + workflow_dispatch: + schedule: + # * is a special character in YAML so you have to quote this string + # Run once a day + - cron: '0 0 * * *' + +jobs: + updatecli: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: tibdex/github-app-token@v1 + id: generate-token + with: + app_id: ${{ secrets.JENKINS_DEPENDENCY_UPDATER_APP_ID }} + private_key: ${{ secrets.JENKINS_DEPENDENCY_UPDATER_PRIVATE_KEY }} + + - name: Diff + uses: updatecli/updatecli-action@v1 + with: + command: diff + flags: "--config ./updatecli/updatecli.d --values updatecli/values.yaml" + env: + UPDATECLI_GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} + + - name: Apply + uses: updatecli/updatecli-action@v1 + with: + flags: "--config ./updatecli/updatecli.d --values updatecli/values.yaml" + env: + UPDATECLI_GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} diff --git a/updatecli/updatecli.d/weekly-apply.sh b/updatecli/updatecli.d/weekly-apply.sh new file mode 100755 index 000000000..5f2081c33 --- /dev/null +++ b/updatecli/updatecli.d/weekly-apply.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# Script "weekly-apply.sh" +# The script checks the current weekly version in the sample plugin +# - if different than $1 and DRY_RUN is set to: +# - "false" then it updates it with the value of $1 +# - "true" then it only reports the value of $1 +# - otherwise it exits without any value reported +existing_version=$(mvn help:evaluate -f sample-plugin -Dexpression=jenkins.version -q -DforceStdout) + +if test "$1" == "$(echo "${existing_version}")" +then + ## No change + # early return with no output + exit 0 +else + if test "$DRY_RUN" == "false" + then + ## Value changed to $1" - NO dry run + mvn versions:set-property -DgenerateBackupPoms=false -Dproperty=jenkins.version -DnewVersion="$1" + fi + # Report on stdout + echo "$1" + exit 0 +fi \ No newline at end of file diff --git a/updatecli/updatecli.d/weekly.yaml b/updatecli/updatecli.d/weekly.yaml new file mode 100644 index 000000000..adb44e607 --- /dev/null +++ b/updatecli/updatecli.d/weekly.yaml @@ -0,0 +1,19 @@ +sources: + newVersion: + name: Get Jenkins Version + kind: maven + spec: + owner: "maven" + url: "repo.jenkins-ci.org" + repository: "releases" + groupID: "org.jenkins-ci.main" + artifactID: "jenkins-war" + +targets: + default: + name: setWeeklyVersion + sourceID: newVersion + kind: shell + spec: + command: bash ./updatecli/updatecli.d/weekly-apply.sh + diff --git a/updatecli/values.yaml b/updatecli/values.yaml new file mode 100644 index 000000000..fcaa3c302 --- /dev/null +++ b/updatecli/values.yaml @@ -0,0 +1,5 @@ +github: + user: "Jenkins dependency updater" + email: "81680575+jenkins-dependency-updater[bot]@users.noreply.github.com" + username: "jenkins-dependency-updater" + token: "UPDATECLI_GITHUB_TOKEN" From 550c43f2eea1d429977240aee7822eb84329b64c Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 21 Oct 2021 08:12:19 +0100 Subject: [PATCH 2/5] Downgrade weekly for testing on CI --- sample-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample-plugin/pom.xml b/sample-plugin/pom.xml index 24013f5c9..c12be34d4 100644 --- a/sample-plugin/pom.xml +++ b/sample-plugin/pom.xml @@ -14,7 +14,7 @@ 999999-SNAPSHOT weekly - 2.317 + 2.316 8 From 3adc5687aba572c8b0f67c59b38684e9c2c395a7 Mon Sep 17 00:00:00 2001 From: Tim Jacomb <21194782+timja@users.noreply.github.com> Date: Thu, 21 Oct 2021 08:17:30 +0100 Subject: [PATCH 3/5] Update updatecli/updatecli.d/weekly-apply.sh --- updatecli/updatecli.d/weekly-apply.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updatecli/updatecli.d/weekly-apply.sh b/updatecli/updatecli.d/weekly-apply.sh index 5f2081c33..55aa14a2e 100755 --- a/updatecli/updatecli.d/weekly-apply.sh +++ b/updatecli/updatecli.d/weekly-apply.sh @@ -21,4 +21,4 @@ else # Report on stdout echo "$1" exit 0 -fi \ No newline at end of file +fi From 8282cbb5d82dcf1cd37ec99512a554efdf08abb0 Mon Sep 17 00:00:00 2001 From: Tim Jacomb <21194782+timja@users.noreply.github.com> Date: Thu, 21 Oct 2021 16:46:52 +0100 Subject: [PATCH 4/5] Update .github/workflows/updatecli.yaml Co-authored-by: Jesse Glick --- .github/workflows/updatecli.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/updatecli.yaml b/.github/workflows/updatecli.yaml index 3a005e2ce..ec5b999f4 100644 --- a/.github/workflows/updatecli.yaml +++ b/.github/workflows/updatecli.yaml @@ -24,13 +24,13 @@ jobs: uses: updatecli/updatecli-action@v1 with: command: diff - flags: "--config ./updatecli/updatecli.d --values updatecli/values.yaml" + flags: "--config updatecli/updatecli.d --values updatecli/values.yaml" env: UPDATECLI_GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} - name: Apply uses: updatecli/updatecli-action@v1 with: - flags: "--config ./updatecli/updatecli.d --values updatecli/values.yaml" + flags: "--config updatecli/updatecli.d --values updatecli/values.yaml" env: UPDATECLI_GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} From 7bd8bdf7f728294e29feb09f076a8eeb94c09470 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Thu, 21 Oct 2021 21:16:59 +0100 Subject: [PATCH 5/5] Review feedback --- .github/workflows/updatecli.yaml | 16 +--------------- updatecli/updatecli.d/weekly-apply.sh | 3 +++ updatecli/values.yaml | 6 +++--- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/updatecli.yaml b/.github/workflows/updatecli.yaml index ec5b999f4..aded772b0 100644 --- a/.github/workflows/updatecli.yaml +++ b/.github/workflows/updatecli.yaml @@ -14,23 +14,9 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - uses: tibdex/github-app-token@v1 - id: generate-token - with: - app_id: ${{ secrets.JENKINS_DEPENDENCY_UPDATER_APP_ID }} - private_key: ${{ secrets.JENKINS_DEPENDENCY_UPDATER_PRIVATE_KEY }} - - - name: Diff - uses: updatecli/updatecli-action@v1 - with: - command: diff - flags: "--config updatecli/updatecli.d --values updatecli/values.yaml" - env: - UPDATECLI_GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} - - name: Apply uses: updatecli/updatecli-action@v1 with: flags: "--config updatecli/updatecli.d --values updatecli/values.yaml" env: - UPDATECLI_GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} + UPDATECLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/updatecli/updatecli.d/weekly-apply.sh b/updatecli/updatecli.d/weekly-apply.sh index 55aa14a2e..0c81d4a25 100755 --- a/updatecli/updatecli.d/weekly-apply.sh +++ b/updatecli/updatecli.d/weekly-apply.sh @@ -1,4 +1,7 @@ #!/bin/bash + +set -eux -o pipefail + # Script "weekly-apply.sh" # The script checks the current weekly version in the sample plugin # - if different than $1 and DRY_RUN is set to: diff --git a/updatecli/values.yaml b/updatecli/values.yaml index fcaa3c302..cf6da4970 100644 --- a/updatecli/values.yaml +++ b/updatecli/values.yaml @@ -1,5 +1,5 @@ github: - user: "Jenkins dependency updater" - email: "81680575+jenkins-dependency-updater[bot]@users.noreply.github.com" - username: "jenkins-dependency-updater" + user: "GitHub Actions" + email: "41898282+github-actions[bot]@users.noreply.github.com" + username: "github-actions" token: "UPDATECLI_GITHUB_TOKEN"