Skip to main content

abbaye/
main.rs

1//! # Abbaye
2//!
3//! ![logo](logo-wordmark.svg)
4//!
5//! Abbaye is a Static Site Generator (SSG) for your software. As GitHub,
6//! Gitea, Forgejo and consorts offer, Abbaye can be used to generate a
7//! website with your software's presentation, documentation, and distribution, per version.
8//!
9//! Here's an example file structure:
10//!
11//! ```text
12//! .
13//! ├── index.html # the main page of the website, enabling choosing a version, defaults to "latest" (contains a list of available versions and a iframe to the selected version?)
14//! ├── releases.feed # the RSS feed of the releases
15//! ├── latest -> v2.0.0 # symlink to the latest version (biggest version number)
16//! ├── v1.0.0/ # the directory containing the version 1.0.0 of the software
17//! │   ├── index.html # the main page of the version 1.0.0, from the README.md file.
18//! │   │   # Contains a sidebar with links to the documentation and distribution.
19//! │   │   # After the readme content, A changelog is displayed.
20//! │   ├── docs/ # the directory containing the documentation of the version 1.0.0
21//! │   │   ├── index.html # the main page of the documentation of the version 1.0.0
22//! │   │   └── …
23//! │   ├── docs.tar.gz # the tarball containing the documentation of the version 1.0.0
24//! │   └── dist/ # the directory containing the distribution of the version 1.0.0
25//! │       ├── source.tgz # the source code of the version 1.0.0
26//! │       ├── mybin-v1.0.0-x86_64-unknown-linux-gnu
27//! │       └── mybin-v1.0.0-x86_64-unknown-linux-musl
28//! └── v2.0.0/ # the directory containing the version 2.0.0 of the software
29//!     ├── index.html # the main page of the version 2.0.0
30//!     ├── …
31//!     └── …
32//! ```
33//!
34//! ## Why the name "Abbaye"?
35//!
36//! An [Abbaye](https://en.wikipedia.org/wiki/Abbaye) is a French word for Abbey. An Abbey is a type of monastery, on the big-ish side, but still a small, quiet place.
37//!
38//! Anyway, that's where you store and display your relics (your software distribution).
39//!
40//! ## Installation
41//!
42//! ### Pre-built binaries
43//!
44//! You can grab a pre-built binary from the [releases page](http://vit.am/~ololduck/abbaye/latest).
45//!
46//! The `-musl` binaries are statically linked and should run everywhere, while the `-gnu` binaries are dynamically linked and require a compatible system library(which is probably available if you're not using an exotic distribution).
47//!
48//! ### From source
49//!
50//! To build from source, you need to have Rust installed. You can install Rust using [rustup](https://rustup.rs/).
51//! If you don't have rust installed, this project won't be of much use to you, as it currently only implements rust builders :stuck_out_tongue:
52//!
53//! You can clone the [repository](https://sr.ht/~ololduck/abbaye) and build the project using `cargo build --release`.
54//!
55//! ## Usage
56//!
57//! Create a `abbaye.toml` configuration file in the root of your project. Here's an example configuration file to get you started:
58//!
59//! ```toml
60//! [site]
61//! name = "Abbaye"
62//!
63//! [version_extractor]
64//! type = "git" # extract version from git tags
65//! tag_prefix = "v"
66//!
67//! [changelog] # use the default changelog parser (Keepachangelog format in CHANGELOG.md)
68//!
69//! [[builders]]  # builds the project using cargo build --release
70//! type = "cargo"
71//! targets = ["x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl"]
72//!
73//! [[builders]]  # generates documentation using cargo doc
74//! type = "cargo_doc"
75//! no_deps = true  # Don't include dependencies in the documentation
76//!
77//! [[builders]]
78//! type = "archive"  # creates a compressed tarball of the source code (can be of anything, really)
79//! ```
80//!
81//! Then run `abbaye` to build the site. The site will be generated in the `public/` directory by default.
82//! Now you can copy the contents of `public/` to your web server to deploy the site. For instance, with rsync:
83//! `rsync --progress -avz --links --perms --update public/ ololduck@vit.am:public_html/abbaye/`
84
85use miette::Result;
86
87/// All builders for the site (ex: cargo build, cargo doc, etc.).
88pub mod builders;
89/// Parses the changelog file and generates a changelog page for the site.
90pub mod changelog;
91/// Handles the `abbaye.toml` configuration file.
92pub mod config;
93/// Generates the site from the configuration and builds it.
94pub mod site;
95/// Extracts current version information from different sources (ex: git tags, cargo metadata, etc.).
96pub mod version_extractors;
97
98#[tokio::main]
99async fn main() -> Result<()> {
100    tracing_subscriber::fmt()
101        .with_timer(tracing_subscriber::fmt::time::SystemTime)
102        .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
103        .init();
104
105    let config = site::load_config()?;
106    site::build_site(config).await
107}