From 75b7cbef8047648da6542426d1978f6fefa19d34 Mon Sep 17 00:00:00 2001 From: jutty Date: Sat, 7 Mar 2026 01:21:59 -0300 Subject: [PATCH] Add 'latest' tag generation, update SourceBuild docs --- .justfile | 54 +++++++++++++++++++++++++++++------------------ Cargo.lock | 2 +- Cargo.toml | 2 +- src/graph/meta.rs | 27 ++++++++++++++++++++++-- static/graph.toml | 16 ++++++++------ 5 files changed, 69 insertions(+), 32 deletions(-) diff --git a/.justfile b/.justfile index 66e7370..44378bd 100644 --- a/.justfile +++ b/.justfile @@ -136,22 +136,23 @@ alias oo := cover-open # Tag HEAD with version from Cargo.toml [script, group: 'assess'] -tag: update && version-assess - last_tag=$(git describe --tags --abbrev=0 \ - $(git rev-list --tags --max-count=1) | tr -d v) - manifest_version=$(grep '^version' Cargo.toml | cut -d \" -f 2) - lockfile_version=$(grep -A 1 'name = "en"' Cargo.lock | - grep version | cut -d '"' -f 2) - - if [ "$last_tag" = "$manifest_version" ]; then - echo "Last tag $last_tag and manifest ($manifest_version) already match" - exit 1 - elif [ "$manifest_version" != "$lockfile_version" ]; then +tag: update + if [ "{{ last_tag }}" = "{{ manifest_version }}" ]; then + echo "Last tag {{ last_tag }} and manifest ({{ manifest_version }}) already match" + if [ "{{ last_tag }}" != "{{ tagged_latest }}" ]; then + echo "Last tag {{ last_tag }} and 'latest' tag ({{ tagged_latest }}) diverge" + git tag latest "v{{ manifest_version }}" + {{ just_cmd }} version-assess + fi + exit + elif [ "{{ manifest_version }}" != "{{ lockfile_version }}" ]; then echo "Manifest and lockfile versions don't match: update failed?" exit 1 fi - git tag "v$manifest_version" HEAD + git tag "v{{ manifest_version }}" HEAD + git tag latest "v{{ manifest_version }}" + {{ just_cmd }} version-assess # Verify and push [group: 'develop'] @@ -267,17 +268,16 @@ alias v := verify # Check tag-manifest consistency [script, group: 'assess'] version-assess: update - last_tag=$(git describe --tags --abbrev=0 \ - $(git rev-list --tags --max-count=1) | tr -d v) - manifest_version=$(grep '^version' Cargo.toml | cut -d \" -f 2) - lockfile_version=$(grep -A 1 'name = "en"' Cargo.lock | - grep version | cut -d '"' -f 2) if - [ "$last_tag" != "$manifest_version" ] || - [ "$last_tag" != "$lockfile_version" ] + [ "{{ last_tag }}" != "{{ tagged_latest }}" ] \ + || [ "{{ last_tag }}" != "{{ lockfile_version }}" ] \ + || [ "{{ last_tag }}" != "{{ lockfile_version }}" ] then - printf 'Last tag: %s\nManifest: %s\nLockfile: %s\n' \ - "$last_tag" "$manifest_version" "$lockfile_version" + printf 'Last tag: %s\nManifest: %s\nLockfile: %s\nTagged latest: %s\n' \ + "{{ last_tag }}" \ + "{{ manifest_version }}" \ + "{{ lockfile_version }}" \ + "{{ tagged_latest }}" exit 1 fi @@ -349,4 +349,16 @@ watch_cmd := "watchexec -qc -r -e rs,toml,html --color always -- " cover_cmd := 'cargo llvm-cov --color always --ignore-filename-regex "main\.rs|log\.rs"' just_cmd := 'just --timestamp --explain --command-color green' +last_tag := ``` + git tag --sort=-creatordate \ + | grep -v '^latest$' | head -1 | tr -d v + ``` +tagged_latest := `git tag --points-at $(git rev-parse latest) \ + | grep -v '^latest$' | tr -d v` +manifest_version := `grep "^version" Cargo.toml | cut -d \" -f 2` +lockfile_version := ``` + grep -A 1 'name = "en"' Cargo.lock \ + | grep version | cut -d '"' -f 2 + ``` + set unstable diff --git a/Cargo.lock b/Cargo.lock index d99fc08..1b418d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -259,7 +259,7 @@ dependencies = [ [[package]] name = "en" -version = "0.1.0" +version = "0.1.0-alpha" dependencies = [ "axum", "serde", diff --git a/Cargo.toml b/Cargo.toml index fe2cf4a..19bb40c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "en" -version = "0.1.0" +version = "0.1.0-alpha" description = "A non-linear writing instrument." license = "AGPL-3.0-only" diff --git a/src/graph/meta.rs b/src/graph/meta.rs index 85b6cd8..776ff9a 100644 --- a/src/graph/meta.rs +++ b/src/graph/meta.rs @@ -117,6 +117,7 @@ pub struct Version { major: u8, minor: u8, patch: u8, + qualifier: Option, } impl Default for Version { @@ -129,6 +130,7 @@ impl Default for Version { major: 0, minor: 0, patch: 0, + qualifier: None, } }, } @@ -137,7 +139,15 @@ impl Default for Version { impl std::fmt::Display for Version { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - write!(f, "{}.{}.{}", self.major, self.minor, self.patch) + if let Some(qualifier) = &self.qualifier { + write!( + f, + "{}.{}.{}-{qualifier}", + self.major, self.minor, self.patch + ) + } else { + write!(f, "{}.{}.{}", self.major, self.minor, self.patch) + } } } @@ -212,7 +222,13 @@ impl Version { let patch: u8 = if triple.len() >= 3 && let Some(s) = triple.get(2) { - match s.trim().parse() { + let patch_number = if let Some(split) = s.split_once('-') { + split.0 + } else { + s + }; + + match patch_number.trim().parse() { Ok(parsed) => parsed, Err(e) => { return Err(VersionError { @@ -228,6 +244,12 @@ impl Version { }); }; + let qualifier: Option = if let Some(tail) = triple.get(2) { + tail.split_once('-').map(|split| String::from(split.1)) + } else { + None + }; + let conditions = has_two_dots && has_three_elements && !has_whitespace @@ -240,6 +262,7 @@ impl Version { major, minor, patch, + qualifier, }) } else { Err(VersionError { diff --git a/static/graph.toml b/static/graph.toml index 92fc356..60440f9 100644 --- a/static/graph.toml +++ b/static/graph.toml @@ -18,8 +18,8 @@ If you are on another platform or simply paranoid, you can also build en yoursel You will need: -- For compiling en, a |Rust toolchain|https://rustup.rs/ -- For compiling dependencies, a C toolchain +- For en itself, a |Rust compiler|https://rustup.rs/ +- For dependencies, a C compiler (e.g. `gcc`) Given the above is satisfied, you can build directly through Cargo: @@ -29,7 +29,7 @@ cargo install --git https://codeberg.org/jutty/en And you should now have the `en` command available on your shell. -For more information on building from source, see |SourceBuild|. +For more details on building from source, see |SourceBuild|. ## Usage @@ -106,7 +106,7 @@ hidden = true [nodes.SourceBuild] text = """ -Building from source is briefly described in the |Documentation| page. +An overview on building from source is available in the |Documentation| page. This page contains a more detailed and considered approach for those interested. Source builds are tested on both Debian and Alpine, meaning en should compile and run on both glibc and musl systems. @@ -114,7 +114,9 @@ Source builds are tested on both Debian and Alpine, meaning en should compile an A Rust toolchain is required to build en itself and can be installed through |rustup|https://rustup.rs/|. -For compiling en dependencies, you will need a C compiler and a libc (e.g. `gcc` + `glibc` or `clang` + `musl`), which may already be installed on your system +For compiling en dependencies, you will also need a C toolchain: a compiler and a libc (e.g. `gcc` + `glibc` or `clang` + `musl`), which may already be installed on your system. + +For the two tested systems, all you need are the following packages: % Distribution ! Needed packages @@ -122,11 +124,11 @@ For compiling en dependencies, you will need a C compiler and a libc (e.g. `gcc` *Alpine* | `clang` % -You may also need `curl` or `git` depending on how you will fetch sources. +You may also need `curl`, `git` and `ca-certificates` depending on how you will fetch the source code. ## Building from a Git clone -Aside from the `cargo install` approach described in |Documentation|, ou can alternatively fetch the code yourself first using Git: +Aside from the `cargo install` approach described in |Documentation|, ou can alternatively fetch the code yourself using Git, which allows you to inspect and change it before compiling: ` git clone https://codeberg.org/jutty/en