Skip to content

Commit

Permalink
Fix bug with creating bumped pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Nov 6, 2024
1 parent 55f97b5 commit f937462
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ jobs:
- name: Bump Version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bb ci:bump-version-and-push "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" "${{ github.actor }}"
run: bb ci:bump-version-and-push "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com" "${{ github.actor }}" --force
4 changes: 2 additions & 2 deletions bb.edn
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
:args->opts [:version]}))}

ci:bump-version-and-push
{:doc "Usage: bb bump-version <email> <user-name> [--dry]"
{:doc "Usage: bb bump-version <email> <user-name> [--dry] [--force]"
:task (t/bump-version!
(cli/parse-opts *command-line-args* {:restrict [:email :user-name :dry]
(cli/parse-opts *command-line-args* {:restrict [:email :user-name :dry :force]
:require [:email :user-name]
:args->opts [:email :user-name]}))}

Expand Down
41 changes: 21 additions & 20 deletions scripts/tasks.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
(:require [babashka.process :as p]
[clojure.string :as string]
publish
util
[babashka.cli :as cli]))
util))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn publish! [args]
Expand All @@ -15,18 +14,20 @@
(println changelog-text)))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn bump-version! [{:keys [user-email user-name dry]}]
(println "Bumping version")
(util/sh dry "git" "config" "--global" "user.email" user-email)
(util/sh dry "git" "config" "--global" "user.name" user-name)
(util/sh dry "npm" "set" "git-tag-version" "false")
(util/sh dry "npm" "version" "patch")
(util/sh dry "git" "add" ".")
(let [version (-> (util/sh false "node" "-p" "require('./package').version")
:out
string/trim)]
(util/sh dry "git" "commit" "-m" (str "Bring on version " version "!")))
(util/sh dry "git" "push" "origin" "HEAD"))
(defn bump-version! [{:keys [user-email user-name dry force]}]
(if force
(do
(println "Bumping version")
(util/shell dry "git" "config" "--global" "user.email" user-email)
(util/shell dry "git" "config" "--global" "user.name" user-name)
(util/shell dry "npm" "version" "--no-git-tag-version" "patch")
(util/shell dry "git" "add" ".")
(let [version (-> (util/sh false "node" "-p" "require('./package').version")
:out
string/trim)]
(util/shell dry "git" "commit" "-m" (str "Bring on version " version "!")))
(util/shell dry "git" "push" "origin" "HEAD"))
(println "Use --force to actually bump the version")))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn package-pre-release! [{:keys [branch dry]}]
Expand All @@ -36,20 +37,20 @@
:out string/trim)
random-slug (util/random-slug 2)
slugged-branch (string/replace branch #"/" "-")
pre-id (str slugged-branch "-" commit-id "-" random-slug)]
version (str current-version "-" slugged-branch "-" commit-id "-" random-slug)]
(println "Current version:" current-version)
(println "HEAD Commit ID:" commit-id)
(println "Packaging pre-release...")
(println (:out (util/sh dry "npm" "version" "--no-git-tag-version" "prerelease" "--preid" pre-id)))
(println (:out (util/sh dry "npx" "vsce" "package" "--pre-release")))
(println (:out (util/sh dry "npm" "version" "--no-git-tag-version" current-version)))))
(util/shell dry "npm" "version" version)
(util/shell dry "npx" "vsce" "package" "--pre-release")
(util/shell dry "npm" "version" "--no-git-tag-version" current-version)))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn run-e2e-tests-with-vsix! [{:keys [vsix]}]
(println "Running end-to-end tests using vsix:" vsix)
(p/shell "node" "./e2e-test-ws/launch.js" (str "--vsix=" vsix)))
(util/shell false "node" "./e2e-test-ws/launch.js" (str "--vsix=" vsix)))

#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn run-e2e-tests-from-working-dir! []
(println "Running end-to-end tests using working directory")
(p/shell "node" "./e2e-test-ws/launch.js"))
(util/shell false "node" "./e2e-test-ws/launch.js"))
9 changes: 9 additions & 0 deletions scripts/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
(throw-if-error
(apply p/sh args)))))

(defn shell [dry-run? & args]
(if dry-run?
(do (println "Dry run:" (apply pr-str args))
{:exit 0})
(do
(apply println args)
(flush)
(apply p/shell args))))

(defn random-slug [n]
(let [chars "abcdefghijklmnopqrstuvwxyz"]
(apply str (repeatedly n #(rand-nth chars)))))
Expand Down

0 comments on commit f937462

Please sign in to comment.