Skip to content

Commit 9266573

Browse files
committed
Update to version 0.16.1
1 parent 6259d00 commit 9266573

File tree

5 files changed

+191
-8
lines changed

5 files changed

+191
-8
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
This file documents the changes made to the formatter with each release. This project uses [semantic versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## Release 0.16.1 (2025-11-10)
6+
7+
### Fixed
8+
9+
- Godot addon: Use standard output mode to avoid overwriting the file on disk
10+
11+
### Changed
12+
13+
- Moved make_release and benchmark scripts to src/bin folder to avoid build errors
14+
515
## Release 0.16.0 (2025-11-09)
616

717
### Added

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "gdscript-formatter"
3-
version = "0.16.0"
3+
version = "0.16.1"
44
edition = "2024"
55
description = "A GDScript code formatter and linter using Topiary and Tree-sitter"
66
license = "MIT"
@@ -30,10 +30,6 @@ gdscript = []
3030
name = "gdscript-formatter"
3131
path = "src/main.rs"
3232

33-
[[bin]]
34-
name = "benchmark"
35-
path = "src/scripts/benchmark.rs"
36-
3733
[profile.release]
3834
strip = true
3935
lto = true

src/bin/make_release.rs

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/// Release automation script for GDScript Formatter
2+
///
3+
/// This script automates the release process by:
4+
/// 1. Prompting for version bump type (major, minor, or patch)
5+
/// 2. Verifying the git tag doesn't already exist
6+
/// 3. Updating the version in Cargo.toml
7+
/// 4. Running `cargo update` to update Cargo.lock
8+
/// 5. Running `cargo build --release` to verify the build works
9+
/// 6. Committing the changes with a standardized message
10+
/// 7. Creating a git tag with the new version
11+
/// 8. Generating a changelog and copying it to clipboard
12+
///
13+
/// Usage:
14+
/// cargo run --bin make_release
15+
///
16+
/// After the script completes, you'll need to manually push:
17+
/// git push origin main
18+
/// git push origin <version>
19+
use std::fs;
20+
use std::io::{self, Write};
21+
use std::process::{Command, exit};
22+
23+
fn main() {
24+
println!("=== GDScript Formatter Release Script ===\n");
25+
26+
let cargo_toml = fs::read_to_string("Cargo.toml").expect("Failed to read Cargo.toml");
27+
28+
let current_version = cargo_toml
29+
.lines()
30+
.find(|line| line.starts_with("version = "))
31+
.and_then(|line| line.split('"').nth(1))
32+
.expect("Failed to find version in Cargo.toml");
33+
34+
println!("Current version: {}", current_version);
35+
36+
let parts: Vec<&str> = current_version.split('.').collect();
37+
if parts.len() != 3 {
38+
eprintln!("Invalid version format");
39+
exit(1);
40+
}
41+
let (major, minor, patch) = (
42+
parts[0].parse::<u32>().unwrap(),
43+
parts[1].parse::<u32>().unwrap(),
44+
parts[2].parse::<u32>().unwrap(),
45+
);
46+
47+
print!("\nVersion bump type? [major/minor/patch]: ");
48+
io::stdout().flush().unwrap();
49+
let mut bump_type = String::new();
50+
io::stdin().read_line(&mut bump_type).unwrap();
51+
let bump_type = bump_type.trim().to_lowercase();
52+
53+
let new_version = match bump_type.as_str() {
54+
"major" => format!("{}.0.0", major + 1),
55+
"minor" => format!("{}.{}.0", major, minor + 1),
56+
"patch" => format!("{}.{}.{}", major, minor, patch + 1),
57+
_ => {
58+
eprintln!("Invalid bump type. Use major, minor, or patch.");
59+
exit(1);
60+
}
61+
};
62+
63+
println!("\nNew version will be: {}", new_version);
64+
65+
let tag_exists = Command::new("git")
66+
.args(&["rev-parse", &new_version])
67+
.output()
68+
.map(|output| output.status.success())
69+
.unwrap_or(false);
70+
71+
if tag_exists {
72+
eprintln!("Error: Git tag '{}' already exists!", new_version);
73+
exit(1);
74+
}
75+
76+
println!("✓ Git tag does not exist");
77+
78+
let updated_cargo_toml = cargo_toml.replace(
79+
&format!("version = \"{}\"", current_version),
80+
&format!("version = \"{}\"", new_version),
81+
);
82+
fs::write("Cargo.toml", updated_cargo_toml).expect("Failed to write Cargo.toml");
83+
println!("✓ Updated Cargo.toml");
84+
85+
println!("\nRunning cargo update...");
86+
let update_status = Command::new("cargo")
87+
.arg("update")
88+
.status()
89+
.expect("Failed to run cargo update");
90+
91+
if !update_status.success() {
92+
eprintln!("cargo update failed");
93+
exit(1);
94+
}
95+
println!("✓ cargo update successful");
96+
97+
println!("\nRunning cargo build...");
98+
let build_status = Command::new("cargo")
99+
.args(&["build", "--release"])
100+
.status()
101+
.expect("Failed to run cargo build");
102+
103+
if !build_status.success() {
104+
eprintln!("cargo build failed");
105+
exit(1);
106+
}
107+
println!("✓ cargo build successful");
108+
109+
println!("\nAdding files to git...");
110+
let add_status = Command::new("git")
111+
.args(&["add", "Cargo.toml", "Cargo.lock"])
112+
.status()
113+
.expect("Failed to run git add");
114+
115+
if !add_status.success() {
116+
eprintln!("git add failed");
117+
exit(1);
118+
}
119+
120+
let commit_msg = format!("Update to version {}", new_version);
121+
let commit_status = Command::new("git")
122+
.args(&["commit", "-m", &commit_msg])
123+
.status()
124+
.expect("Failed to run git commit");
125+
126+
if !commit_status.success() {
127+
eprintln!("git commit failed");
128+
exit(1);
129+
}
130+
println!("✓ Committed changes");
131+
132+
let tag_status = Command::new("git")
133+
.args(&["tag", &new_version])
134+
.status()
135+
.expect("Failed to run git tag");
136+
137+
if !tag_status.success() {
138+
eprintln!("git tag failed");
139+
exit(1);
140+
}
141+
println!("✓ Created tag '{}'", new_version);
142+
143+
println!("\nGenerating changelog...");
144+
let shortlog_output = Command::new("git")
145+
.args(&["shortlog", &format!("{}..HEAD", current_version)])
146+
.output()
147+
.expect("Failed to run git shortlog");
148+
149+
let shortlog = String::from_utf8_lossy(&shortlog_output.stdout);
150+
println!("\n--- Changelog ---");
151+
println!("{}", shortlog);
152+
println!("--- End Changelog ---\n");
153+
154+
let clipcopy_status = Command::new("clipcopy")
155+
.stdin(std::process::Stdio::piped())
156+
.spawn()
157+
.and_then(|mut child| {
158+
if let Some(mut stdin) = child.stdin.take() {
159+
stdin.write_all(shortlog.as_bytes())?;
160+
}
161+
child.wait()
162+
});
163+
164+
match clipcopy_status {
165+
Ok(status) if status.success() => {
166+
println!("✓ Changelog copied to clipboard");
167+
}
168+
_ => {
169+
println!("⚠ Failed to copy to clipboard (clipcopy might not be available)");
170+
}
171+
}
172+
173+
println!("\n=== Release {} ready! ===", new_version);
174+
println!("\nNext steps:");
175+
println!(" git push origin main");
176+
println!(" git push origin {}", new_version);
177+
}

0 commit comments

Comments
 (0)