diff --git a/tools/automator/src/args.rs b/tools/automator/src/args.rs index 9eb4d3a17..31ee0123c 100644 --- a/tools/automator/src/args.rs +++ b/tools/automator/src/args.rs @@ -14,6 +14,7 @@ impl Args { #[derive(clap::Subcommand)] pub enum Blog { Release, + SponsorUpdate, } #[derive(clap::Parser)] diff --git a/tools/automator/src/blog/mod.rs b/tools/automator/src/blog/mod.rs index bc732c847..5e8b60478 100644 --- a/tools/automator/src/blog/mod.rs +++ b/tools/automator/src/blog/mod.rs @@ -1,4 +1,7 @@ mod release; +mod sponsors; mod util; -pub use self::release::create_release_announcement; +pub use self::{ + release::create_release_announcement, sponsors::create_sponsor_update, +}; diff --git a/tools/automator/src/blog/sponsors.rs b/tools/automator/src/blog/sponsors.rs new file mode 100644 index 000000000..39cb1f6c1 --- /dev/null +++ b/tools/automator/src/blog/sponsors.rs @@ -0,0 +1,58 @@ +use std::fmt::Write; + +use tokio::{fs::File, io::AsyncWriteExt}; + +use super::util; + +pub async fn create_sponsor_update() -> anyhow::Result<()> { + let month = util::now_ym(); + let date = util::now_ymd(); + + let mut file = util::create_blog_post_file("sponsors", &month).await?; + generate_update(date, month, &mut file).await?; + + Ok(()) +} + +async fn generate_update( + date: String, + month: String, + file: &mut File, +) -> anyhow::Result<()> { + let mut buf = String::new(); + write!( + buf, + "\ ++++ +title = \"Sponsor Update - {month}\" +date = {date} + +# Uncomment to generate the HTML for the email newsletter. +# template = \"newsletter/email.html\" ++++ + +Hey folks! + +I just sent out the new sponsor update! Topics this month include: + +- **TASK: Summarize sponsor update.** + +If you want to receive monthly behind-the-scenes updates too, why not support Fornjot by [becoming a sponsor](https://github.com/sponsors/hannobraun)? You can start with as little as $2 a month. More substantial contributions are also welcome, of course 😁 + +I dedicate a substantial chunk of my week to working on Fornjot. Your contribution can help make that more sustainable. + + +### Not receiving these updates? + +I've been sending out an update every month since February 2022. If you are a sponsor and haven't received those updates, maybe you are not opted in? Update your sponsorship over at GitHub, and make sure you check `Receive email updates from hannobraun`. Also make sure to check the spam folder in your email client. + +If you still haven't received an update, [please contact me](mailto:hanno@braun-odw.eu). I'm happy to send you a copy directly. + +I'm sorry for any inconvenience! Unfortunately, GitHub gives me no control over, or insight into, who is receiving those updates. +" + )?; + + file.write_all(buf.as_bytes()).await?; + + Ok(()) +} diff --git a/tools/automator/src/blog/util.rs b/tools/automator/src/blog/util.rs index aa0b00218..a9beee4a5 100644 --- a/tools/automator/src/blog/util.rs +++ b/tools/automator/src/blog/util.rs @@ -4,6 +4,11 @@ use anyhow::Context; use chrono::{Datelike, Utc}; use tokio::fs::{self, File}; +pub fn now_ym() -> String { + let now = Utc::now(); + format!("{}-{:02}", now.year(), now.month()) +} + pub fn now_ymd() -> String { let now = Utc::now(); format!("{}-{:02}-{:02}", now.year(), now.month(), now.day()) diff --git a/tools/automator/src/run.rs b/tools/automator/src/run.rs index 993f81585..6413ff6ef 100644 --- a/tools/automator/src/run.rs +++ b/tools/automator/src/run.rs @@ -20,6 +20,11 @@ pub async fn run() -> anyhow::Result<()> { .await .context("Failed to create release announcement")?; } + Args::Blog(Blog::SponsorUpdate) => { + blog::create_sponsor_update() + .await + .context("Failed to create sponsor update")?; + } Args::Sponsors(args) => { let min_dollars = 8; let sponsors = Sponsors::query(&octocrab)