Skip to content
This repository was archived by the owner on Nov 30, 2025. It is now read-only.

Commit c6a225e

Browse files
committed
init commit
feat: add workflow test test tist tstienars tosetn chorentoiersn storset sin iresnt rositne tiersnt
0 parents  commit c6a225e

7 files changed

Lines changed: 241 additions & 0 deletions

File tree

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use_flake
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: JDTLS Milestone Release Checker
2+
3+
on:
4+
schedule:
5+
# Runs daily at midnight UTC
6+
- cron: "0 0 * * *"
7+
push:
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
check-and-release:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v3
22+
23+
- name: Get latest jdtls version
24+
id: get_latest
25+
run: |
26+
pip install requests
27+
echo "latest_version=$(python ./get_latest.py)" >> $GITHUB_ENV
28+
29+
- name: Check if latest version has been released
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
echo "Fetching releases for repository..."
34+
releases=$(curl -H "Authorization: Bearer $GITHUB_TOKEN" \
35+
-H "Accept: application/vnd.github.v3+json" \
36+
https://api.github.com/repos/${{ github.repository }}/releases)
37+
38+
if echo "$releases" | jq -e '.[] | select(.tag_name == "${{ env.latest_version }}")' > /dev/null; then
39+
echo "release_exists=true" >> $GITHUB_ENV
40+
else
41+
echo "release_exists=false" >> $GITHUB_ENV
42+
fi
43+
44+
- name: Repackage jdtls
45+
if: env.release_exists == 'false'
46+
run: |
47+
pip install requests
48+
python ./repackage.py
49+
ls
50+
51+
- name: Release
52+
if: env.release_exists == 'false'
53+
uses: softprops/action-gh-release@v2
54+
with:
55+
files: jdtls.tar.gz
56+
make_latest: "true"
57+
name: "${{env.latest_version}}"
58+
tag_name: "${{env.latest_version}}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.direnv

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
description = "A devShell example";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{
11+
nixpkgs,
12+
flake-utils,
13+
...
14+
}:
15+
flake-utils.lib.eachDefaultSystem (
16+
system:
17+
let
18+
pkgs = import nixpkgs { inherit system; };
19+
in
20+
with pkgs;
21+
{
22+
devShells.default = mkShell {
23+
buildInputs = [
24+
python310
25+
(python310Packages.requests)
26+
];
27+
28+
shellHook = ''
29+
alias ls=eza
30+
alias find=fd
31+
'';
32+
};
33+
}
34+
);
35+
}

get_latest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import re
2+
import requests
3+
4+
base_url = 'https://download.eclipse.org/jdtls/milestones/'
5+
6+
def get_latest_version():
7+
milestones_res = requests.get(base_url, allow_redirects=True)
8+
if(milestones_res.status_code != 200):
9+
raise Exception('Failed to get all versions from milestones page')
10+
version_match_regex = r"<a href='(.*?)'> (\d*.\d*.\d*.)</a>"
11+
matches = re.findall(version_match_regex, milestones_res.text)
12+
versions = [match[1] for match in matches]
13+
14+
sorted_versions = sorted(versions, key=lambda x: list(map(int, x.split('.'))))
15+
return sorted_versions[-1]
16+
version = get_latest_version()
17+
print(version)

repackage.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import re
2+
import requests
3+
from urllib.parse import urljoin
4+
import urllib.request
5+
import tarfile
6+
import os
7+
import tempfile
8+
from shutil import move, copyfile
9+
10+
base_url = 'https://download.eclipse.org/jdtls/milestones/'
11+
12+
def get_latest_version():
13+
milestones_res = requests.get(base_url, allow_redirects=True)
14+
if(milestones_res.status_code != 200):
15+
raise Exception('Failed to get all versions from milestones page')
16+
version_match_regex = r"<a href='(.*?)'> (\d*.\d*.\d*.)</a>"
17+
matches = re.findall(version_match_regex, milestones_res.text)
18+
versions = [match[1] for match in matches]
19+
20+
sorted_versions = sorted(versions, key=lambda x: list(map(int, x.split('.'))))
21+
return sorted_versions[-1]
22+
23+
def get_jdtls_download_url(version):
24+
url = urljoin(base_url, f'{version}/latest.txt')
25+
pkg_name_res = requests.get(url)
26+
file_name = pkg_name_res.text.strip()
27+
return urljoin(base_url, f'{version}/{file_name}')
28+
29+
def get_equinox_launcher_name(version):
30+
plugins_res = requests.get(f"https://download.eclipse.org/jdtls/milestones/{version}/repository/plugins/")
31+
pattern = r"<a .*?>(org.eclipse.equinox.launcher_.*?.jar)</a>"
32+
matches = re.findall(pattern, plugins_res.text)
33+
34+
if len(matches) < 1:
35+
raise Exception('Could not find the equinox launcher plugin')
36+
37+
if len(matches) > 1:
38+
raise Exception('Found more than one equinox launcher plugin')
39+
40+
return matches[0]
41+
42+
def download_file(url):
43+
with tempfile.TemporaryDirectory() as tmp:
44+
res = requests.get(url)
45+
file_path = urljoin(tmp, 'jdtls.tar.gz')
46+
with open(file_path, 'wb') as file:
47+
file.write(res.content)
48+
return file_path
49+
50+
def extract_tar_gz(tar_gz_path, equinox_plugin_path):
51+
with tarfile.open(tar_gz_path, "r:gz") as tar:
52+
with tempfile.TemporaryDirectory() as tmp:
53+
ex_dir = f'{tmp}/jdtls'
54+
tar.extractall(path=ex_dir)
55+
move(f'{ex_dir}/plugins/{equinox_plugin_path}', f'{ex_dir}/plugins/org.eclipse.equinox.launcher.jar')
56+
with tempfile.TemporaryDirectory() as tmpout:
57+
out_path = f'{tmpout}/jdtls.tar.gz'
58+
with tarfile.open(out_path, "w:gz") as tarout:
59+
for file in os.listdir(ex_dir):
60+
tarout.add(f'{ex_dir}/{file}',arcname=file, recursive=True)
61+
copyfile(f'{tmpout}/jdtls.tar.gz', './jdtls.tar.gz')
62+
63+
64+
version = get_latest_version()
65+
download_url = get_jdtls_download_url(version)
66+
equinox_plugin_path = get_equinox_launcher_name(version)
67+
downloaded_path = download_file(download_url)
68+
extract_tar_gz(downloaded_path, equinox_plugin_path)

0 commit comments

Comments
 (0)