mirror of
https://github.com/roswell/roswell.git
synced 2026-09-10 07:16:17 -04:00
129 lines
5 KiB
Common Lisp
Executable file
129 lines
5 KiB
Common Lisp
Executable file
#!/bin/sh
|
|
#|-*- mode:lisp -*-|#
|
|
#|
|
|
exec ros -Q -L sbcl-bin -- $0 "$@"
|
|
|#
|
|
(ql:quickload :cl-ppcre)
|
|
(defvar *project-path* (truename (merge-pathnames "../" (make-pathname :name nil :type nil :defaults *load-pathname*))))
|
|
(defvar *new-version* nil)
|
|
|
|
(defun find-version ()
|
|
(with-open-file (in (merge-pathnames "configure.ac" *project-path*))
|
|
(loop for line = (read-line in nil nil)
|
|
while line
|
|
for match = (nth-value 1 (cl-ppcre:scan-to-strings "^AC_INIT\\([^,]*,\\[([^,]*)\\]" line))
|
|
when match
|
|
do (return-from find-version (aref match 0)))))
|
|
|
|
(defun inc-version (v)
|
|
(let ((pos (position-if (complement #'digit-char-p) v :from-end t)))
|
|
(if pos
|
|
(format nil "~A~A"
|
|
(subseq v 0 (1+ pos))
|
|
(1+ (parse-integer (subseq v (1+ pos)))))
|
|
v)))
|
|
|
|
(defun edit-configure-ac ()
|
|
(let ((file (with-open-file (in (merge-pathnames "configure.ac" *project-path*)
|
|
:direction :input)
|
|
(loop for line = (read-line in nil nil)
|
|
while line
|
|
for match = (nth-value 1 (cl-ppcre:scan-to-strings "^AC_INIT\\([^,]*,\\[([^,]*)\\]" line))
|
|
collect (if match
|
|
(cl-ppcre:regex-replace "^(AC_INIT\\([^,]*,\\[)([^,]*)(\\].*)$" line
|
|
(format nil "\\{1}~A\\{3}" *new-version*))
|
|
line))
|
|
)))
|
|
(with-open-file (out (merge-pathnames "configure.ac" *project-path*)
|
|
:direction :output :if-exists :supersede)
|
|
(dolist (line file)
|
|
(format out "~A~%" line)))))
|
|
|
|
(defun x (cmd)
|
|
(string-right-trim
|
|
(format nil "~A" #\newline)
|
|
(with-output-to-string (o)
|
|
(uiop/run-program:run-program cmd :output o))))
|
|
|
|
(defun edit-change-log ()
|
|
(with-open-file (out (merge-pathnames "ChangeLog--" *project-path*)
|
|
:direction :output :if-exists :supersede)
|
|
(format out "~{~A~%~}"
|
|
(list (format nil "roswell (~A-1) unstable; urgency=low" *new-version*)
|
|
"" " *" ""
|
|
(format nil " -- ~A <~A> ~A"
|
|
(x "git config --get user.name")
|
|
(x "git config --get user.email")
|
|
(x "LANG=C date -R")) "")))
|
|
(with-open-file (out (merge-pathnames "ChangeLog---" *project-path*)
|
|
:direction :output :if-exists :supersede)
|
|
(uiop/run-program:run-program
|
|
(format nil "cat ~A ~A"
|
|
(merge-pathnames "ChangeLog--" *project-path*)
|
|
(merge-pathnames "ChangeLog" *project-path*))
|
|
:output out))
|
|
(uiop/run-program:run-program
|
|
(format nil "mv ~A ~A"
|
|
(merge-pathnames "ChangeLog---" *project-path*)
|
|
(merge-pathnames "ChangeLog" *project-path*)))
|
|
(uiop/run-program:run-program
|
|
(format nil "rm -f ~A ~A"
|
|
(merge-pathnames "ChangeLog--" *project-path*)
|
|
(merge-pathnames "ChangeLog---" *project-path*))))
|
|
|
|
(defun show-how-to-release ()
|
|
(format t "~{~A~%~}~%"
|
|
`("To release"
|
|
"1. Review changes and complete ChangeLog"
|
|
"2. Type"
|
|
"make release"
|
|
"3. don't forget to release homeberew-roswell as well followings are snmsts's"
|
|
"ros scripts/homebrew.ros"
|
|
"cp scripts/homebrew/roswell.rb ../homebrew-roswell/roswell.rb"
|
|
"cd ../homebrew-roswell/"
|
|
"git add roswell.rb"
|
|
,(format nil "git commit -m \"v~A\"" *new-version*)
|
|
"git push")))
|
|
|
|
(defun prepare ()
|
|
(uiop/run-program:run-program "git checkout master" :output t)
|
|
(format t "~¤t version is ~s.How about new one's:~%" (find-version))
|
|
(force-output)
|
|
(setq *new-version* (read-line))
|
|
(when (zerop (length *new-version*))
|
|
(setf *new-version* (inc-version (find-version))))
|
|
(format t "~&new version name is ~S~%" *new-version*)
|
|
(force-output)
|
|
(edit-change-log)
|
|
(edit-configure-ac)
|
|
(show-how-to-release))
|
|
|
|
(defun release ()
|
|
(if (not (uiop:getenv "GITHUB_OAUTH_TOKEN"))
|
|
(error "GITHUB_OAUTH_TOKEN must be set")
|
|
(let ((version (find-version)))
|
|
(mapc
|
|
#'uiop:run-program
|
|
`("git add ChangeLog configure.ac"
|
|
,(format nil "git commit -m \"bump version to ~A\"" version)
|
|
"git checkout release"
|
|
"git merge master"
|
|
,(format nil "git tag -a \"v~A\" -m \"v~A\"" version version)
|
|
"git push --tags"
|
|
"git push --all"
|
|
"git checkout master"))
|
|
(load (merge-pathnames "../sn.github/sn.github.asd" *project-path*))
|
|
(ql:quickload :sn.github :silent t)
|
|
(let ((tag (string-right-trim (format nil"~%")
|
|
(uiop/run-program:run-program
|
|
"git tag |tail -n 1" :output :string))))
|
|
(print (funcall (read-from-string "sn.github.release::release-create")
|
|
"snmsts" "roswell" tag :name tag))))))
|
|
|
|
(defun main (subcmd &rest argv)
|
|
(declare (ignorable argv))
|
|
(cond ((equalp subcmd "prepare")
|
|
(prepare))
|
|
((equalp subcmd "release")
|
|
(release))))
|