-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce
release_archive
rule (#211)
- The `release_archive` rule produces an archive file that preserves the permissions on the provided files. The `pkg_tar` rule does not. - Remove `rules_pkg`. - Update `bazel-starlib` release to use `release_archive`. Related to #200.
- Loading branch information
Showing
36 changed files
with
166 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"""Definition for `release_archive` rule.""" | ||
|
||
def _release_archive_impl(ctx): | ||
out_basename = ctx.attr.out | ||
if out_basename == "": | ||
out_basename = "{name}{ext}".format( | ||
name = ctx.label.name, | ||
ext = ctx.attr.ext, | ||
) | ||
out = ctx.actions.declare_file(out_basename) | ||
|
||
# Write the file list to a file | ||
file_list_out = ctx.actions.declare_file(ctx.label.name + "_files") | ||
file_list_args = ctx.actions.args() | ||
file_list_args.add_all(ctx.files.srcs) | ||
ctx.actions.write( | ||
output = file_list_out, | ||
content = file_list_args, | ||
) | ||
|
||
# Create the archive | ||
args = ctx.actions.args() | ||
args.add(out) | ||
args.add(file_list_out) | ||
ctx.actions.run_shell( | ||
outputs = [out], | ||
inputs = [file_list_out] + ctx.files.srcs, | ||
arguments = [args], | ||
command = """\ | ||
archive="$1" | ||
file_list="$2" | ||
shift 1 | ||
tar 2>/dev/null -hczvf "$archive" -T "${file_list}" | ||
""", | ||
) | ||
return DefaultInfo( | ||
files = depset([out]), | ||
runfiles = ctx.runfiles(files = [out]), | ||
) | ||
|
||
release_archive = rule( | ||
implementation = _release_archive_impl, | ||
attrs = { | ||
"ext": attr.string( | ||
default = ".tar.gz", | ||
doc = "The extension for the archive.", | ||
), | ||
"out": attr.string( | ||
doc = "The name of the output file.", | ||
), | ||
"srcs": attr.label_list( | ||
allow_files = True, | ||
mandatory = True, | ||
), | ||
}, | ||
doc = """\ | ||
Create a source release archive. | ||
This rule uses `tar` to collect and compress files into an archive file \ | ||
suitable for use as a release artifact. Any permissions on the source files \ | ||
will be preserved. | ||
""", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.