Improve minimum version by using shards.yml crystal attribute

This commit is contained in:
Fijxu 2026-08-17 01:39:45 -04:00
parent 143077be07
commit 22e269ba99
No known key found for this signature in database
GPG Key ID: 32C1DDF333EDA6A4
2 changed files with 14 additions and 7 deletions

View File

@ -10,7 +10,7 @@ targets:
main: src/invidious.cr
description: |
Invidious is an alternative front-end to YouTube
Invidious is an alternative front-end to YouTube
dependencies:
pg:
@ -40,7 +40,7 @@ development_dependencies:
github: crystal-ameba/ameba
version: ~> 1.6.1
crystal: ">= 1.10.0, < 2.0.0"
crystal: ">= 1.20.0, < 2.0.0"
license: AGPL-3.0-only

View File

@ -54,11 +54,18 @@ require "./invidious/jobs/*"
# encouraging the user compiling Invidious, to update it's Crystal compiler
# version.
{% begin %}
{% minimum_version = "1.14.1" %}
{% if compare_versions(Crystal::VERSION, minimum_version) < 0 %}
{{ raise "Crystal version #{minimum_version} or newer is required to build Invidious. \
You currently have Crystal version #{Crystal::VERSION} installed. \
We recommend that you install it following the way that the Crystal compiler itself recommend for your OS, see: https://crystal-lang.org/install/" }}
# `-Dskip_version_check` compile-time flag, for development purposes
# or weird installations that lack the `shard.yml` file when compiling
# Invidious.
{% if !flag?(:skip_version_check) %}
{% shard_yml = read_file("shard.yml") %}
{% crystal_constraint = shard_yml.split('\n').find { |line| line.starts_with?("crystal:") } %}
{% minimum_version = crystal_constraint.split('"')[1].split(",").first.split(">=").last.strip %}
{% if compare_versions(Crystal::VERSION, minimum_version) < 0 %}
{{ raise "Crystal version #{minimum_version} or newer is required to build Invidious. \
You currently have Crystal version #{Crystal::VERSION} installed. \
We recommend that you install it following the way that the Crystal compiler itself recommend for your OS, see: https://crystal-lang.org/install/" }}
{% end %}
{% end %}
{% end %}