Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/get_version.yml
Original file line number Diff line number Diff line change
@@ -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"
42 changes: 42 additions & 0 deletions .github/workflows/update_bundle_version.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions Eask
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
24 changes: 24 additions & 0 deletions scripts/_prepare.el
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions scripts/latest-tag.el
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions scripts/update-bundle-version.el
Original file line number Diff line number Diff line change
@@ -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