Skip to content

Commit

Permalink
chore: release script cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Aug 9, 2024
1 parent e5cbb98 commit dc04800
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 49 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
external
dist
.cache
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root = true

[*]
end_of_line = lf
8 changes: 4 additions & 4 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ setup_7zip()

http_archive(
name = "rules_blender",
sha256 = "05acad9716ec6c80cadb603e7f585acbaadf670bce6920959824122e25e97e9c",
strip_prefix = "rules_blender-dc8c77bdb27e4af7cb1c95610a119a8ad64e57c7",
urls = ["https://github.com/zaucy/rules_blender/archive/dc8c77bdb27e4af7cb1c95610a119a8ad64e57c7.zip"],
integrity = "sha256-HKH9Y2wiL/EkVEFcaCZHT8ACW8SHX24UZ8EHEhwcI8w=",
strip_prefix = "rules_blender-e5f5b1ef894fe4da7b3cbf85ca857b6fd3bdffba",
urls = ["https://github.com/zaucy/rules_blender/archive/e5f5b1ef894fe4da7b3cbf85ca857b6fd3bdffba.zip"],
)

load("@rules_blender//:repo.bzl", "blender_repository")

blender_repository(name = "blender")
blender_repository(name = "blender", blender_version = "system", only_system_installed_blender = True)

http_archive(
name = "ecsact_logo",
Expand Down
93 changes: 48 additions & 45 deletions release.nu
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
def get-ecsact-deps [] {
(buildozer -output_json 'print name version' //MODULE.bazel:%bazel_dep
| from json
| get records
| each {|record| {name: $record.fields.0.text, version: $record.fields.1.text?} }
| filter {|dep| $dep.name | str starts-with "ecsact_"}
)
}

def main [version: string] {
let start_dir = $env.PWD;
let before_update_deps = get-ecsact-deps;
let changelog_template = [$start_dir, "release-notes-template"] | path join;

$before_update_deps | each {|dep| bzlmod add $dep.name; };

let release_notes = (get-ecsact-deps | each {|dep|
let before_version = $before_update_deps | where name == $dep.name | get version | get 0;
let after_version = $dep | get version;
let dep_repo_remote = $"https://github.com/ecsact-dev/($dep.name)";
let cached_repo_dir = $".cache/repos/($dep.name)";
mut dep_release_notes = "";

if $after_version != $before_version {
rm -rf $cached_repo_dir;
git clone --quiet $dep_repo_remote $cached_repo_dir;
cd $cached_repo_dir;
let changelog = cog changelog $"($before_version)..($after_version)" -o ecsact-dev --repository $dep.name --remote "github.com" -t $changelog_template;
rm -rf $cached_repo_dir;
cd $start_dir;
$dep_release_notes += $"# ($dep.name) ($before_version) -> ($after_version)\n\n";
$dep_release_notes += $changelog;
}

$dep_release_notes
});

let release_notes = $release_notes | reduce {|$section, $full| $full + $section} -f "";
git add MODULE.bazel;
git commit -m $"chore\(deps\): ecsact repos for ($version) release";
git push origin main;
git tag $version;
git push origin $version;
gh release create $version -n $release_notes --latest -t $version --verify-tag --latest;
}
def get-ecsact-deps [] {
(buildozer -output_json 'print name version' //MODULE.bazel:%bazel_dep
| from json
| get records
| each {|record| {name: $record.fields.0.text, version: $record.fields.1.text?} }
| filter {|dep| $dep.name | str starts-with "ecsact_"}
)
}

def main [version: string] {
let start_dir = $env.PWD;
let before_update_deps = get-ecsact-deps;
let changelog_template = [$start_dir, "release-notes-template"] | path join;

$before_update_deps | each {|dep| bzlmod add $dep.name; };

# sanity check
bazel build //...;

let release_notes = (get-ecsact-deps | each {|dep|
let before_version = $before_update_deps | where name == $dep.name | get version | get 0;
let after_version = $dep | get version;
let dep_repo_remote = $"https://github.com/ecsact-dev/($dep.name)";
let cached_repo_dir = $".cache/repos/($dep.name)";
mut dep_release_notes = "";

if $after_version != $before_version {
rm -rf $cached_repo_dir;
git clone --quiet $dep_repo_remote $cached_repo_dir;
cd $cached_repo_dir;
let changelog = cog changelog $"($before_version)..($after_version)" -o ecsact-dev --repository $dep.name --remote "github.com" -t $changelog_template;
rm -rf $cached_repo_dir;
cd $start_dir;
$dep_release_notes += $"# ($dep.name) ($before_version) -> ($after_version)\n\n";
$dep_release_notes += $changelog;
}

$dep_release_notes
});

let release_notes = $release_notes | reduce {|$section, $full| $full + $section} -f "";
git add MODULE.bazel;
git commit -m $"chore\(deps\): ecsact repos for ($version) release";
git push origin main;
git tag $version;
git push origin $version;
gh release create $version -n $release_notes --latest -t $version --verify-tag --latest;
}

0 comments on commit dc04800

Please sign in to comment.