Automating GitHub Weekly Labels: My New Rust Tool
If you’ve ever spent time managing GitHub repositories, you know that labels can make or break your workflow. They help organize issues, track progress, and make project dashboards readable at a glance. But let’s be honest: manually creating labels for every repository in an organization — especially weekly labels — can quickly become tedious. That’s why I decided to automate the process.
Enter my latest side project: a Rust CLI tool that generates weekly labels and applies them to all repositories in a GitHub organization, complete with a color gradient that visualizes the progression from week 1 to week 52. Check out my GitHub repo: https://github.com/ReneKrewinkel/gen-weeks
Why I Built This
I love the command line. I love automating repetitive tasks. And I love seeing things happen programmatically instead of clicking around in a web interface. Managing labels manually ticked all the boxes for “tedious, error-prone, and time-consuming.” Instead of adding week-2025-47, week-2025-48, … by hand across all repos, I wanted a tool that:
- Creates weekly labels automatically.
- Assigns consistent colors so you can glance at a week and immediately know where it fits in the year.
- Forces labels to exist: if a label already exists, it updates it with the new color/description.
- Works across all existing repositories without extra manual effort.
- Integrates directly with GitHub Projects, allowing me to use views to filter issues by week.
Rust was a natural choice because I like typed safety, fast compilation, and powerful HTTP libraries. Using reqwest for GitHub API calls and chrono for week calculations made the tool clean, minimal, and robust. How It Works
The tool does a few simple things:
- Reads a configuration JSON with your GitHub token and organization name.
- Calculates the ISO week numbers for the next N weeks (default 26, or half a year).
- Generates a color for each week along a gradient from light yellow to dark purple.
- Projects integration: Using GitHub Projects views, I can filter issues by week label to track progress in a visual, organized way.
- Loops through all repositories in the organization:
- If a label does not exist, it creates it.
- If a label exists, it updates the color and description to keep everything consistent.
Here’s a snippet showing how the color gradient is calculated:
pub fn week_color(week: u32) -> String {
let week = week.clamp(1, 52);
let start_hue = 200.0; // light blue
let end_hue = 270.0; // purple
let hue = start_hue + (end_hue - start_hue) * ((week - 1) as f32 / 51.0);
let s = 0.65;
let l = 0.55;
let (r, g, b) = hsl_to_rgb(hue, s, l);
format!("{:02x}{:02x}{:02x}", (r * 255.0) as u8, (g * 255.0) as u8, (b * 255.0) as u8)
}
And this is how the tool forces labels to exist or updates them if they already do:
let resp = client
.post(&format!("https://api.github.com/repos/{}/{}/labels", org_name, repo_name))
.bearer_auth(&github_token)
.header("User-Agent", "week-labeler")
.json(&body)
.send();
match resp {
Ok(r) if r.status().is_success() => println!("Created label {}", label_name),
Ok(r) if r.status().as_u16() == 422 => {
// Label exists, update it
client
.patch(&format!("https://api.github.com/repos/{}/{}/labels/{}", org_name, repo_name, label_name))
.bearer_auth(&github_token)
.header("User-Agent", "week-labeler")
.json(&body)
.send()
.unwrap();
println!("Updated existing label {}", label_name);
}
Ok(r) => eprintln!("Failed to create label {}: {:?}", label_name, r.text()),
Err(e) => eprintln!("Request failed for label {}: {:?}", label_name, e),
}
Why I Love This Approach
- Predictable and consistent: All labels for the same week share the same color.
- Re-runnable: Run the tool next week, and it updates existing labels without duplicating them.
- Minimalist design: Just one CLI, one config file, no external dependencies beyond GitHub.
- Scalable: Works for any organization size, regardless of how many repos you have.
- Projects-friendly: Weekly labels integrate directly with GitHub Projects views for easy filtering.
The Color Gradient
- Week 1 → light blue
- Week 52 → dark purple
This allows your team to instantly see how issues relate to the week of the year, across all repositories and project boards.
What’s Next
I’m thinking of adding a GitHub Actions workflow so that new repositories automatically inherit the weekly labels when they’re created. Another improvement would be a visual CLI dashboard showing which weeks have labels already applied across the org.
If you spend any significant amount of time managing multiple repos, I can’t recommend automating label creation enough. It’s one of those little quality-of-life improvements that makes you fall in love with the command line all over again, especially when combined with GitHub Projects views.
Contributing Feel free to open issues or submit pull requests for new features, such as:
- GitHub Actions integration
- Parallelized label updates
- Custom color gradients
Repo: https://github.com/ReneKrewinkel/gen-weeks
Read the full article here: https://blog.krewinkel.studio/automating-github-weekly-labels-my-new-rust-tool-98ad71346f37