Skip to content

Commit 736f2a7

Browse files
committed
Add auto upgrade script
1 parent 64bdf4a commit 736f2a7

2 files changed

Lines changed: 103 additions & 1 deletion

File tree

.github/workflows/auto-release.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Auto Release
2+
on:
3+
schedule:
4+
- cron: 0 12 * * *
5+
workflow_dispatch:
6+
permissions:
7+
contents: write
8+
jobs:
9+
auto-release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v5.0.0
14+
with:
15+
token: ${{ secrets.TOOLBOX_REPO_TOKEN }}
16+
fetch-depth: 0
17+
18+
- name: Set up JDK
19+
uses: actions/setup-java@v5.0.0
20+
with:
21+
java-version: '21'
22+
distribution: temurin
23+
24+
- name: Setup Gradle
25+
uses: gradle/actions/setup-gradle@v5.0.0
26+
27+
- name: Update library versions
28+
run: ./gradlew versionCatalogUpdate
29+
shell: bash
30+
31+
- name: Update Gradle wrapper
32+
# Run twice: the first pass updates gradle-wrapper.properties,
33+
# the second pass regenerates gradle-wrapper.jar + gradlew scripts
34+
# using the new version.
35+
run: |
36+
./gradlew wrapper --gradle-version=latest --distribution-type=bin
37+
./gradlew wrapper --gradle-version=latest --distribution-type=bin
38+
shell: bash
39+
40+
- name: Check for changes
41+
id: changes
42+
run: |
43+
if git diff --quiet; then
44+
echo "has_changes=false" >> $GITHUB_OUTPUT
45+
else
46+
echo "has_changes=true" >> $GITHUB_OUTPUT
47+
fi
48+
shell: bash
49+
50+
- name: Verify build still passes
51+
if: steps.changes.outputs.has_changes == 'true'
52+
run: ./gradlew check
53+
shell: bash
54+
55+
- name: Compute next version
56+
if: steps.changes.outputs.has_changes == 'true'
57+
id: version
58+
run: |
59+
CURRENT=$(jq -r '.http4k.version' version.json)
60+
IFS='.' read -r MAJOR MINOR _ _ <<< "$CURRENT"
61+
NEW="$MAJOR.$((MINOR + 1)).0.0"
62+
echo "Bumping $CURRENT -> $NEW"
63+
echo "current=$CURRENT" >> $GITHUB_OUTPUT
64+
echo "new=$NEW" >> $GITHUB_OUTPUT
65+
shell: bash
66+
67+
- name: Rewrite version references
68+
if: steps.changes.outputs.has_changes == 'true'
69+
env:
70+
CURRENT: ${{ steps.version.outputs.current }}
71+
NEW: ${{ steps.version.outputs.new }}
72+
run: |
73+
find . -name "*.md" -not -name "CHANGELOG*" -print0 \
74+
| xargs -0 perl -i -pe 's/\Q$ENV{CURRENT}\E/$ENV{NEW}/g'
75+
perl -i -pe 's/\Q$ENV{CURRENT}\E/$ENV{NEW}/g' version.json
76+
shell: bash
77+
78+
- name: Prepend CHANGELOG entry
79+
if: steps.changes.outputs.has_changes == 'true'
80+
env:
81+
NEW: ${{ steps.version.outputs.new }}
82+
# upload-release.yml extracts the section matching the version for the
83+
# GitHub release notes, so the new entry has to land in CHANGELOG.md
84+
# before the commit. Inserts directly above the previous top entry.
85+
run: |
86+
perl -i -pe 'BEGIN { $inserted = 0 }
87+
if (!$inserted && /^### /) {
88+
print "### $ENV{NEW}\n- Upgrade underlying libraries (Gradle etc)\n\n";
89+
$inserted = 1;
90+
}' CHANGELOG.md
91+
shell: bash
92+
93+
- name: Commit and push release
94+
if: steps.changes.outputs.has_changes == 'true'
95+
env:
96+
NEW: ${{ steps.version.outputs.new }}
97+
run: |
98+
git config user.name github-actions
99+
git config user.email github-actions@github.com
100+
git commit -am "Release $NEW"
101+
git push origin HEAD:main
102+
shell: bash

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)