Skip to content

Commit

Permalink
Prepare for releasing rules_jsonnet 0.6.0 (#187)
Browse files Browse the repository at this point in the history
* Automate the release process

This change imports a GitHub workflow that is similar to the one we have
in rules_python that gets launched when new tags are created. We can use
that to automatically perform releases on GitHub and attach a stable
source tarball.

Issue: #170

* Use zero version numbers in helper modules

These will always use the very latest version of the source code that's
present in this repository. There is no need to fill in an exact number
here.

* Bump the version number of the rules_jsonnet module to 0.6.0

I think that it makes sense to cut a new release of rules_jsonnet. First
and foremost because this will be the first official release to support
bzlmod. It also addresses the import path issue that prevents people
from using these rules in multi-workspace environments.
  • Loading branch information
EdSchouten authored Apr 4, 2024
1 parent c74493b commit 0dc6e87
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 4 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/create_archive_and_notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit -o nounset -o pipefail

# Set by GH actions, see
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
TAG=${GITHUB_REF_NAME}
# A prefix is added to better match the GitHub generated archives.
PREFIX="rules_jsonnet-${TAG}"
ARCHIVE="rules_jsonnet-$TAG.tar.gz"
git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE
SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}')

cat > release_notes.txt << EOF
## Setup
To use the Jsonnet rules, add the following to your \`MODULE.bazel\` file:
\`\`\`starlark
bazel_dep(name = "rules_jsonnet", version = "${TAG}")
\`\`\`
If you are using an older version of Bazel that does not support Bzlmod,
add the following to your \`WORKSPACE\` file to add the external
repositories for Jsonnet:
\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_jsonnet",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
urls = ["https://github.com/bazelbuild/rules_jsonnet/releases/download/${TAG}/rules_jsonnet-${TAG}.tar.gz",
)
load("@io_bazel_rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_repositories")
jsonnet_repositories()
load("@google_jsonnet_go//bazel:repositories.bzl", "jsonnet_go_repositories")
jsonnet_go_repositories()
load("@google_jsonnet_go//bazel:deps.bzl", "jsonnet_go_dependencies")
jsonnet_go_dependencies()
\`\`\`
EOF
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Cut a release whenever a new tag is pushed to the repo.
name: Release

on:
push:
tags:
- "*.*.*"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create release archive and notes
run: .github/workflows/create_archive_and_notes.sh
- name: Release
uses: softprops/action-gh-release@v1
with:
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
fail_on_unmatched_files: true
files: rules_python-*.tar.gz
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module(
name = "rules_jsonnet",
version = "0.5.0",
version = "0.6.0",
repo_name = "io_bazel_rules_jsonnet",
)

Expand Down
2 changes: 1 addition & 1 deletion docs/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module(
bazel_dep(name = "aspect_bazel_lib", version = "2.7.0")
bazel_dep(name = "stardoc", version = "0.6.2")

bazel_dep(name = "rules_jsonnet", version = "0.5.0")
bazel_dep(name = "rules_jsonnet", version = "0.0.0")
local_path_override(
module_name = "rules_jsonnet",
path = "..",
Expand Down
2 changes: 1 addition & 1 deletion examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module(
version = "0.0.0",
)

bazel_dep(name = "rules_jsonnet", version = "0.5.0")
bazel_dep(name = "rules_jsonnet", version = "0.0.0")
local_path_override(
module_name = "rules_jsonnet",
path = "..",
Expand Down
2 changes: 1 addition & 1 deletion examples/other_module/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ module(
version = "0.0.0",
)

bazel_dep(name = "rules_jsonnet", version = "0.5.0")
bazel_dep(name = "rules_jsonnet", version = "0.0.0")

0 comments on commit 0dc6e87

Please sign in to comment.