Skip to content

Commit

Permalink
add Babashka task to fetch force SNAPSHOT tags
Browse files Browse the repository at this point in the history
jackdbd committed Oct 4, 2024
1 parent 0f5c50c commit e8f9705
Showing 3 changed files with 22 additions and 10 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
@@ -46,11 +46,10 @@ jobs:
echo "pod_version=$POD_VERSION" >> $GITHUB_OUTPUT
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
echo "PRERELEASE=false" >> $GITHUB_ENV
echo "prerelease=false" >> $GITHUB_OUTPUT
else
echo "PRERELEASE=true" >> $GITHUB_ENV
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
echo "prerelease=$PRERELEASE" >> $GITHUB_OUTPUT
- name: Log job outputs
run: |
@@ -329,7 +328,7 @@ jobs:
clojars:
name: Publish to Clojars
if: ${{ github.event_name != 'pull_request' }}
# needs: [linux, macos, windows] # publish only when all tests on all platforms pass
needs: [linux, macos, windows] # publish only when all tests on all platforms pass
runs-on: ubuntu-latest

steps:
@@ -448,9 +447,7 @@ jobs:
id: github_release
with:
body: |
This is a release of **${{ env.POD_NAME }}** version `${{ env.POD_VERSION }}`.
The pod is also [published as an uberjar to Clojars](https://clojars.org/com.github.jackdbd/pod.jackdbd.jsoup).
📦 **${{ env.POD_NAME }}** version `${{ env.POD_VERSION }}` is [available on Clojars](https://clojars.org/com.github.jackdbd/pod.jackdbd.jsoup/versions/${{ env.POD_VERSION }}).
# draft: true
fail_on_unmatched_files: true
files: |
9 changes: 7 additions & 2 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -68,8 +68,13 @@
;; bb snapshot [patch|minor|major]
:task (tasks/snapshot (keyword (first *command-line-args*)))}

stable {:doc "Promote the current SNAPSHOT version to stable"
:task (tasks/stable)}
stable
{:doc "Promote the current SNAPSHOT version to stable"
:task (tasks/stable)}

sync-tags
{:doc "Run git fetch --force on all v*.*.*-SNAPSHOT tags"
:task (tasks/fetch-force-snapshot-tags)}

test
{:doc "Run all tests"
12 changes: 11 additions & 1 deletion bb/tasks.bb
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@

(defn print-classpath []
(println "=== CLASSPATH BEGIN ===")
;; (System/getProperty "java.class.path")
(doseq [path (set (split-classpath (get-classpath)))]
(println path))
(println "=== CLASSPATH END ==="))
@@ -52,6 +51,17 @@
(shell ["git" "tag" "-a" (format "v%s" stable-version) "--message" message])
(shell (format "git push --atomic")))))

(defn fetch-force-snapshot-tags []
(let [remote-tags (->> (sh "git" "ls-remote" "--tags" "origin")
:out
str/split-lines
(map #(second (str/split % #"\s+")))
(filter #(re-find #"v\d+\.\d+\.\d+-SNAPSHOT" %)))]
(doseq [tag remote-tags]
(let [tag-name (last (str/split tag #"/"))]
(println "Fetching and force updating tag:" tag-name)
(sh "git" "fetch" "origin" "tag" tag-name "--force")))))

(comment
(print-classpath)
)

0 comments on commit e8f9705

Please sign in to comment.