66 - ' *'
77
88permissions :
9- contents : read
9+ contents : write
1010 packages : write
1111
1212jobs :
2525 run : |
2626 git fetch origin main --depth=1
2727
28- if ! git merge-base --is-ancestor "$GITHUB_SHA" "origin/main"; then
29- echo "Tag $GITHUB_REF_NAME does not point to a commit on origin/main"
28+ main_sha="$(git rev-parse origin/main)"
29+
30+ if [[ "$GITHUB_SHA" != "$main_sha" ]]; then
31+ echo "Tag $GITHUB_REF_NAME must point to the current origin/main tip"
32+ echo "tag sha: $GITHUB_SHA"
33+ echo "main sha: $main_sha"
3034 exit 1
3135 fi
3236
4044 exit 1
4145 fi
4246
43- if [[ ! "$version" =~ ^[0-9]+( \.[0-9]+){2}([.-] [0-9A-Za-z]+)* $ ]]; then
44- echo "Tag $GITHUB_REF_NAME does not look like a release version "
47+ if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\. [0-9]+ $ ]]; then
48+ echo "Tag $GITHUB_REF_NAME must be in the form vX.Y.Z "
4549 exit 1
4650 fi
4751
@@ -100,7 +104,7 @@ jobs:
100104 RELEASE_VERSION : ${{ needs.verify-release-tag.outputs.version }}
101105 run : |
102106 perl -0pi -e 's/\(defproject\s+dev\.dotfox\/trapperkeeper-webserver-jetty12\s+"[^"]+"/(defproject dev.dotfox\/trapperkeeper-webserver-jetty12 "'"$RELEASE_VERSION"'"/' project.clj
103- rg '^\(defproject ' project.clj
107+ sed -n '1p ' project.clj
104108
105109 - name : Prepare package
106110 run : lein with-profile +provided do clean, jar
@@ -121,3 +125,48 @@ jobs:
121125 export DEPLOY_PASSWORD="${DEPLOY_PASSWORD_OVERRIDE:-$DEFAULT_DEPLOY_PASSWORD}"
122126
123127 lein with-profile +provided deploy releases
128+
129+ bump-snapshot-version :
130+ name : Bump main to next snapshot
131+ needs : [verify-release-tag, publish-package]
132+ runs-on : ubuntu-latest
133+ steps :
134+ - name : Check out main
135+ uses : actions/checkout@v4
136+ with :
137+ fetch-depth : 0
138+ ref : main
139+
140+ - name : Verify main did not move
141+ run : |
142+ git fetch origin main
143+
144+ main_sha="$(git rev-parse origin/main)"
145+
146+ if [[ "$main_sha" != "$GITHUB_SHA" ]]; then
147+ echo "origin/main moved during the release run; refusing to bump version automatically"
148+ echo "tag sha: $GITHUB_SHA"
149+ echo "main sha: $main_sha"
150+ exit 1
151+ fi
152+
153+ - name : Set next snapshot version
154+ env :
155+ RELEASE_VERSION : ${{ needs.verify-release-tag.outputs.version }}
156+ run : |
157+ IFS='.' read -r major minor patch <<< "$RELEASE_VERSION"
158+ next_patch=$((patch + 1))
159+ next_version="${major}.${minor}.${next_patch}-SNAPSHOT"
160+
161+ perl -0pi -e 's/\(defproject\s+dev\.dotfox\/trapperkeeper-webserver-jetty12\s+"[^"]+"/(defproject dev.dotfox\/trapperkeeper-webserver-jetty12 "'"$next_version"'"/' project.clj
162+ sed -n '1p' project.clj
163+
164+ - name : Commit next snapshot version
165+ run : |
166+ git config user.name "github-actions[bot]"
167+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
168+ git add project.clj
169+ git commit -m "Prepare next development version"
170+
171+ - name : Push snapshot bump to main
172+ run : git push origin HEAD:main
0 commit comments