From 7917d1c7cb226f26f6b67967c99ac93a822b66c9 Mon Sep 17 00:00:00 2001 From: FichteFoll Date: Sun, 12 Jan 2025 14:47:52 +0100 Subject: [PATCH] Fetch latest "stable" build from update check endpoint --- .github/workflows/test.yml | 24 ++++++++++++------------ README.md | 6 ++++-- syntax-tests.sh | 30 ++++++++++++++++++++---------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e54c1b3..71ce901 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,32 +3,32 @@ name: Tests on: [push, pull_request] jobs: - no_defpkg: - name: Without default packages + no_defpkg_stable: + name: Without default packages, latest stable runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./ with: - build: 4189 + build: stable package_root: test/no_defpkg # TODO indentation tests # TODO reference & definition tests - defpkg: + defpkg_stable: name: With default packages, latest stable runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./ with: - build: 4189 + build: stable default_packages: master package_root: test/defpkg no_defpkg_old_build: - name: Without default packages, old build + name: Without default packages, build 4073 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -47,8 +47,8 @@ jobs: build: latest package_root: test/no_defpkg - third-party: - name: Third-party + third-party_stable: + name: Third-party, latest stable runs-on: ubuntu-latest steps: - name: Checkout repo (primary package) @@ -61,19 +61,19 @@ jobs: path: third-party/INI - uses: ./ with: - build: 4189 # stable + build: stable package_root: test/third-party additional_packages: third-party/INI - dummy_syntax: - name: Dummy Syntax + dummy_syntax_stable: + name: Dummy Syntax, latest stable runs-on: ubuntu-latest steps: - name: Checkout repo (primary package) uses: actions/checkout@v4 - uses: ./ with: - build: 4189 # stable + build: stable package_root: test/dummy-syntax dummy_syntaxes: text.dummy diff --git a/README.md b/README.md index 579f62e..7955eae 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,10 @@ jobs: include: - build: latest # This is the default # packages: master # If you depend on a default syntax definition + - build: stable # Fetches the binary for the latest stable build + # packages: v4189 # Latest stable tag at the time of writing. - build: 3210 # Latest known ST3 build with a test binary - # packages: v3189 # Latest ST3 tag on the Packages repo + # packages: v3189 # Latest ST3 tag on the Packages repo steps: - uses: actions/checkout@v4 - uses: SublimeText/syntax-test-action@v2 @@ -136,7 +138,7 @@ jobs: | Name | Default | Description | | :----------------------- | :-------------- | :---------- | -| **build** | `"latest"` | ST build that should be installed as an integer. Not all builds are available. | +| **build** | `"latest"` | ST build that should be installed as an integer. `"latest"` is for the dev channel, `"stable"` for the stable channel. Not all builds are available. | | **default\_packages** | `false` | Install the [default packages][] and which version (accepts any git ref, e.g. `"master"`). | | **default\_tests** | `false` | Whether to keep the tests of the default packages. | | **additional\_packages** | `""` | Comma-separated list of paths to additionally checked out packages to install (e.g.: `LESS,third-party/Sass`). Uses the folders' base names as the package names to install as. | diff --git a/syntax-tests.sh b/syntax-tests.sh index 20eb37d..a2429b4 100755 --- a/syntax-tests.sh +++ b/syntax-tests.sh @@ -8,23 +8,33 @@ packages="$folder/Data/Packages" mkdir -p "$folder" get_url() { - latest_url="https://download.sublimetext.com/latest/dev/linux/x64/syntax_tests" - template_3000="https://download.sublimetext.com/st3_syntax_tests_build_%s_x64.tar.bz2" - template_4000="https://download.sublimetext.com/st_syntax_tests_build_%s_x64.tar.bz2" - template_4079="https://download.sublimetext.com/st_syntax_tests_build_%s_x64.tar.xz" + local latest_url="https://download.sublimetext.com/latest/dev/linux/x64/syntax_tests" + local template_3000="https://download.sublimetext.com/st3_syntax_tests_build_%s_x64.tar.bz2" + local template_4000="https://download.sublimetext.com/st_syntax_tests_build_%s_x64.tar.bz2" + local template_4079="https://download.sublimetext.com/st_syntax_tests_build_%s_x64.tar.xz" + local build="$INPUT_BUILD" + + if [[ $INPUT_BUILD == stable ]]; then + get_latest_stable_build | read -r build + echo "Latest stable build: $build" + fi - case $INPUT_BUILD in + case $build in latest) echo "$latest_url";; - 3*) printf "$template_3000\n" "$INPUT_BUILD";; - 4*) if (( INPUT_BUILD < 4079 )); then - printf "$template_4000\n" "$INPUT_BUILD"; + 3*) printf "$template_3000\n" "$build";; + 4*) if (( build < 4079 )); then + printf "$template_4000\n" "$build"; else - printf "$template_4079\n" "$INPUT_BUILD"; + printf "$template_4079\n" "$build"; fi;; - *) echo >&2 "Invalid build reference: $INPUT_BUILD"; exit 100;; + *) echo >&2 "Invalid build reference: $build"; exit 100;; esac } +get_latest_stable_build() { + curl "https://www.sublimetext.com/updates/4/stable_update_check" | jq '.latest_version' +} + fetch_binary() { read -r url local tmpdir