Skip to content

Commit

Permalink
Fetch latest "stable" build from update check endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
FichteFoll committed Jan 12, 2025
1 parent 2310304 commit 2bf13fb
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 24 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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. |
Expand Down
30 changes: 20 additions & 10 deletions syntax-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 [[ $build == stable ]]; then
build="$(get_latest_stable_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
Expand Down

0 comments on commit 2bf13fb

Please sign in to comment.