diff --git a/.github/workflows/get_version.yml b/.github/workflows/get_version.yml new file mode 100644 index 0000000..512bb59 --- /dev/null +++ b/.github/workflows/get_version.yml @@ -0,0 +1,41 @@ +name: Get Version + +on: + workflow_call: + outputs: + version: + description: The latest `tree-sitter-langs` Version + value: ${{ jobs.get-version.outputs.VERSION }} + inputs: + workflow_ref: + description: 'Must be the same as "uses: ...@THIS"' + default: master + required: false + type: string + +env: + EMACS_VER: 30.2 + +jobs: + get-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.expose-ver.outputs.VERSION }} + steps: + - uses: jcs090218/setup-emacs@master + with: + version: ${{ env.EMACS_VER }} + + - uses: emacs-eask/setup-eask@master + with: + version: 'snapshot' + + - uses: actions/checkout@v5 + + - name: Expose Version + id: expose-ver + run: | + eask install-deps --dev + VERSION=$(eask load scripts/latest-tag.el) + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "$VERSION" diff --git a/.github/workflows/update_bundle_version.yml b/.github/workflows/update_bundle_version.yml new file mode 100644 index 0000000..09c5027 --- /dev/null +++ b/.github/workflows/update_bundle_version.yml @@ -0,0 +1,42 @@ +name: Update Bundle Version + +on: + schedule: + - cron: '0 * * * *' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + get-version: + uses: emacs-tree-sitter/treesit-langs/.github/workflows/get_version.yml@master + + main: + needs: [get-version] + runs-on: ubuntu-latest + env: + VERSION: ${{ needs.get-version.outputs.version }} + steps: + - uses: actions/checkout@v5 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Expose bundle version + run: | + echo "BUNDLE_VER=${{ env.VERSION }}" >> $GITHUB_ENV + + - name: Update Bundle Version + run: | + eask run script update-bundle-version + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + title: 'Update Bundle Version to ${{ env.VERSION }}' + body: '' + commit-message: 'Update Bundle Version to ${{ env.VERSION }}' + branch: submodules-update + delete-branch: true diff --git a/Eask b/Eask index ee48212..56229d7 100644 --- a/Eask +++ b/Eask @@ -10,8 +10,14 @@ (package-file "treesit-langs.el") (script "test" "echo \"Error: no test specified\" && exit 1") +(script "update-bundle-version" "eask load scripts/update-bundle-version.el") (source 'gnu) (source 'melpa) +(source 'jcs-elpa) (depends-on "emacs" "29.1") + +(development + (depends-on "elenv") + (depends-on "github-tags")) diff --git a/scripts/_prepare.el b/scripts/_prepare.el new file mode 100644 index 0000000..955b47a --- /dev/null +++ b/scripts/_prepare.el @@ -0,0 +1,24 @@ +;;; _prepare.el --- Prepration -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(require 'cl-lib) +(require 'subr-x) + +(require 'elenv) + +(defun get-latest-tag () + "Return the latest tag (not including pre-release)." + (require 'github-tags) + (if-let* ((repo "emacs-tree-sitter/tree-sitter-langs") + (response (cdr (github-tags repo))) + (tags (plist-get response :names)) + (latest (nth 1 tags))) ; Skip the first one since it's the pre-release! + latest + (user-error "[ERROR] Latest tag not found in repository: %s" repo))) + +;; Local Variables: +;; coding: utf-8 +;; no-byte-compile: t +;; End: +;;; _prepare.el ends here diff --git a/scripts/latest-tag.el b/scripts/latest-tag.el new file mode 100644 index 0000000..2ee3a0a --- /dev/null +++ b/scripts/latest-tag.el @@ -0,0 +1,13 @@ +;;; latest-tag.el --- Print latest tag -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(load-file "./scripts/_prepare.el") + +(princ (get-latest-tag)) + +;; Local Variables: +;; coding: utf-8 +;; no-byte-compile: t +;; End: +;;; latest-tag.el ends here diff --git a/scripts/update-bundle-version.el b/scripts/update-bundle-version.el new file mode 100644 index 0000000..a1f47c4 --- /dev/null +++ b/scripts/update-bundle-version.el @@ -0,0 +1,23 @@ +;;; update-bundle-version.el --- Update the bundle version -*- lexical-binding: t -*- +;;; Commentary: +;;; Code: + +(load-file "./scripts/_prepare.el") + +(let ((ver (or (getenv "BUNDLE_VER") + "0.1.0"))) + (with-current-buffer (find-file "treesit-langs.el") + (goto-char (point-min)) + (when (search-forward "(defcustom treesit-langs-bundle-version \"" nil t) + (let ((start (point)) + (end (save-excursion (forward-sexp) (point)))) + (delete-region start end) + (insert ver) + (save-buffer)) + (message "[INFO] Updated the bundle version to `%s`" ver)))) + +;; Local Variables: +;; coding: utf-8 +;; no-byte-compile: t +;; End: +;;; update-bundle-version.el ends here