Skip to content

Commit

Permalink
chore: simplify distribution and release
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Dec 11, 2021
1 parent 4420d07 commit a1a8788
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 90 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ jobs:
# Bazelisk will download bazel to here
XDG_CACHE_HOME: ~/.cache/bazel-repo
run: bazel --bazelrc=.github/workflows/ci.bazelrc --bazelrc=.bazelrc test //...
- name: Prepare workspace snippet
run: .github/workflows/workspace_snippet.sh ${{ env.GITHUB_REF_NAME }} > release_notes.txt
- name: Release
uses: softprops/action-gh-release@v1
with:
prerelease: true
files: bazel-out/*/bin/*.tar.gz
# Use GH feature to populate the changelog automatically
generate_release_notes: true
body_path: release_notes.txt
29 changes: 29 additions & 0 deletions .github/workflows/workspace_snippet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

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}
PREFIX="rules_js-${TAG:1}"
SHA=$(git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip | shasum -a 256 | awk '{print $1}')

cat << EOF
WORKSPACE snippet:
\`\`\`starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_js",
sha256 = "${SHA}",
strip_prefix = "${PREFIX}",
url = "https://github.com/aspect-build/rules_js/archive/${TAG}.tar.gz",
)
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
rules_js_dependencies()
\`\`\`
EOF
24 changes: 0 additions & 24 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load(":version.bzl", "VERSION")
load("@bazel_gazelle//:def.bzl", "gazelle", "gazelle_binary")

gazelle_binary(
Expand All @@ -13,22 +11,6 @@ gazelle(
gazelle = "gazelle_bin",
)

# This declares the release artifact users
pkg_tar(
name = "rules_js-" + VERSION,
srcs = [
"README.md",
"version.bzl",
"//js:package_content",
],
extension = "tar.gz",
# It is all source code, so make it read-only.
mode = "0444",
# Make it owned by root so it does not have the uid of the CI robot.
owner = "0.0",
strip_prefix = ".",
)

bzl_library(
name = "internal_deps",
srcs = ["internal_deps.bzl"],
Expand All @@ -38,9 +20,3 @@ bzl_library(
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)

bzl_library(
name = "version",
srcs = ["version.bzl"],
visibility = ["//visibility:public"],
)
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,5 @@ This means that any usage of `@rules_js` on your system will point to this folde

## Releasing

1. Update the constant in `version.bzl`
1. `git tag v$(grep VERSION version.bzl | cut -d'"' -f2)`
1. git push --tags
1. Push a tag to the repo, or create one on the GH UI
1. Watch the automation run on GitHub actions
1. Update the release page with auto-generated release notes
29 changes: 3 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,9 @@ In addition, as a clean rewrite many of the bugs in rules_nodejs are naturally r

## Installation

Include this in your WORKSPACE file:

```starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_js",
sha256 = "29ede06bb95ec0216bc917aa4b49c3340a448a05bfdd1fbc68a82bbbb21a193d",
url = "https://github.com/aspect-dev/rules_js/releases/download/v0.1.0/rules_js-0.1.0.tar.gz",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

# This fetches the aspect_rules_js dependencies, which are:
# - bazel_skylib
# - rules_nodejs
# - aspect_bazel_lib
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
# Alternatively, you can skip calling this function, so long as you've
# already fetched these dependencies.
rules_js_dependencies()
```

> note, in the above, replace the version and sha256 with the one indicated
> in the release notes for aspect_rules_js
> In the future, our release automation should take care of this.
From the release you wish to use:
<https://github.com/aspect-build/rules_js/releases>
copy the WORKSPACE snippet into your `WORKSPACE` file.

## Usage

Expand Down
10 changes: 0 additions & 10 deletions internal_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

def rules_js_internal_deps():
"Fetch repositories used for developing the rules"
maybe(
http_archive,
name = "rules_pkg",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.2.4/rules_pkg-0.2.4.tar.gz",
"https://github.com/bazelbuild/rules_pkg/releases/download/0.2.4/rules_pkg-0.2.4.tar.gz",
],
sha256 = "4ba8f4ab0ff85f2484287ab06c0d871dcb31cc54d439457d28fd4ae14b18450a",
)

maybe(
http_archive,
name = "build_bazel_integration_testing",
Expand Down
11 changes: 0 additions & 11 deletions js/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ exports_files(
visibility = ["//docs:__pkg__"],
)

filegroup(
name = "package_content",
srcs = glob([
"*.bzl",
"*.bazel",
]) + [
"//js/private:package_content",
],
visibility = ["//:__pkg__"],
)

bzl_library(
name = "nodejs_binary",
srcs = ["nodejs_binary.bzl"],
Expand Down
9 changes: 0 additions & 9 deletions js/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,6 @@ config_setting(
values = {"enable_runfiles": "true"},
)

filegroup(
name = "package_content",
srcs = glob([
"*.bzl",
"*.bazel",
]),
visibility = ["//js:__pkg__"],
)

bzl_library(
name = "nodejs_binary",
srcs = ["nodejs_binary.bzl"],
Expand Down
5 changes: 3 additions & 2 deletions js/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def rules_js_dependencies():
maybe(
http_archive,
name = "aspect_bazel_lib",
sha256 = "7cb2faf813bae1712dcb09b23dd8d68fffd8631a25d54b9ca8ae866ca7debc06",
urls = ["https://github.com/aspect-build/bazel-lib/releases/download/v0.2.1/bazel_lib-0.2.1.tar.gz"],
sha256 = "e834c368f36cb336b5b42cd1dd9cd4b6bafa0ad3ed7f92f54a47e5ab436e4f59",
strip_prefix = "bazel-lib-0.3.0",
url = "https://github.com/aspect-build/bazel-lib/archive/v0.3.0.tar.gz",
)
3 changes: 0 additions & 3 deletions version.bzl

This file was deleted.

0 comments on commit a1a8788

Please sign in to comment.