Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate updating weekly version #689

Merged
merged 5 commits into from
Oct 21, 2021
Merged
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
22 changes: 22 additions & 0 deletions .github/workflows/updatecli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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

- name: Apply
uses: updatecli/updatecli-action@v1
with:
flags: "--config updatecli/updatecli.d --values updatecli/values.yaml"
env:
UPDATECLI_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion sample-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<bom>weekly</bom>
<jenkins.version>2.317</jenkins.version>
<jenkins.version>2.316</jenkins.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Just to see if the workflow will bump it back up again?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

<java.level>8</java.level>
</properties>
<repositories>
Expand Down
27 changes: 27 additions & 0 deletions updatecli/updatecli.d/weekly-apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
timja marked this conversation as resolved.
Show resolved Hide resolved

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:
# - "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)
timja marked this conversation as resolved.
Show resolved Hide resolved

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
19 changes: 19 additions & 0 deletions updatecli/updatecli.d/weekly.yaml
Original file line number Diff line number Diff line change
@@ -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

5 changes: 5 additions & 0 deletions updatecli/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
github:
user: "GitHub Actions"
email: "41898282+github-actions[bot]@users.noreply.github.com"
username: "github-actions"
token: "UPDATECLI_GITHUB_TOKEN"