From d5dc620bb6e75e9908be6a148876cc46353a64b3 Mon Sep 17 00:00:00 2001 From: Chuck Grindel Date: Wed, 12 Jan 2022 15:59:13 -0700 Subject: [PATCH] Implemented release workflow using `bzlrelease`. (#43) Implemented release workflow using bzlrelease. Renamed CI workflow and updated to use cgrindel/gha_set_up_bazel. --- .github/workflows/{bazel.yml => ci.yml} | 16 +++------ .github/workflows/create_release.yml | 45 +++++++++++++++++++++++++ README.md | 3 +- release/BUILD.bazel | 32 ++++++++++++++++++ release/workspace_snippet.tmpl | 44 ++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 13 deletions(-) rename .github/workflows/{bazel.yml => ci.yml} (82%) create mode 100644 .github/workflows/create_release.yml create mode 100644 release/BUILD.bazel create mode 100644 release/workspace_snippet.tmpl diff --git a/.github/workflows/bazel.yml b/.github/workflows/ci.yml similarity index 82% rename from .github/workflows/bazel.yml rename to .github/workflows/ci.yml index d12ba88..e749a7b 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Build +name: CI for PR Merge on: pull_request: @@ -12,17 +12,9 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Write local.bazelrc File - shell: bash - run: | - cat >local.bazelrc < ```python - # Download and configure rules_swiftformat. http_archive( @@ -78,6 +78,7 @@ load("@cgrindel_rules_swiftformat//swiftformat:load_package.bzl", "swiftformat_l swiftformat_load_package() ``` + ### 2. Update the `BUILD.bazel` at the root of your workspace diff --git a/release/BUILD.bazel b/release/BUILD.bazel new file mode 100644 index 0000000..b4391b7 --- /dev/null +++ b/release/BUILD.bazel @@ -0,0 +1,32 @@ +load("@cgrindel_bazel_starlib//bzlformat:defs.bzl", "bzlformat_pkg") +load( + "@cgrindel_bazel_starlib//bzlrelease:defs.bzl", + "create_release", + "generate_release_notes", + "generate_workspace_snippet", + "update_readme", +) + +# MARK: - Release + +generate_workspace_snippet( + name = "generate_workspace_snippet", + template = "workspace_snippet.tmpl", +) + +generate_release_notes( + name = "generate_release_notes", + generate_workspace_snippet = ":generate_workspace_snippet", +) + +update_readme( + name = "update_readme", + generate_workspace_snippet = ":generate_workspace_snippet", +) + +create_release( + name = "create", + workflow_name = "Create Release", +) + +bzlformat_pkg(name = "bzlformat") diff --git a/release/workspace_snippet.tmpl b/release/workspace_snippet.tmpl new file mode 100644 index 0000000..2f81150 --- /dev/null +++ b/release/workspace_snippet.tmpl @@ -0,0 +1,44 @@ +# Download and configure rules_swiftformat. + +${http_archive_statement} + +load("@cgrindel_rules_swiftformat//swiftformat:deps.bzl", "swiftformat_rules_dependencies") + +swiftformat_rules_dependencies() + +# Configure the dependencies for rules_swiftformat + +load( + "@cgrindel_bazel_starlib//:deps.bzl", + "bazel_starlib_dependencies", +) + +bazel_starlib_dependencies() + +load( + "@cgrindel_rules_spm//spm:deps.bzl", + "spm_rules_dependencies", +) + +spm_rules_dependencies() + +load( + "@build_bazel_rules_swift//swift:repositories.bzl", + "swift_rules_dependencies", +) + +swift_rules_dependencies() + +load( + "@build_bazel_rules_swift//swift:extras.bzl", + "swift_rules_extra_dependencies", +) + +swift_rules_extra_dependencies() + +# We are using rules_spm to download and build SwiftFormat. The following will configure +# rules_spm to do that. + +load("@cgrindel_rules_swiftformat//swiftformat:load_package.bzl", "swiftformat_load_package") + +swiftformat_load_package()