Automate producing release tarballs for Bazel (#4113)

This commit is contained in:
JP Simard 2022-08-19 13:26:21 -04:00 committed by GitHub
parent 6dc2ef937e
commit e8f738b39c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 21 deletions

2
.gitignore vendored
View File

@ -44,6 +44,8 @@ benchmark_*
osscheck/
docs/
rule_docs/
bazel.tar.gz
bazel.tar.gz.sha256
# Swift Package Manager
#

34
BUILD
View File

@ -9,6 +9,8 @@ load(
"xcodeproj",
)
# Targets
swift_library(
name = "SwiftLintFramework",
srcs = glob(
@ -40,18 +42,38 @@ swift_binary(
],
)
# Linting
filegroup(
name = "SwiftLintConfig",
srcs = [".swiftlint.yml"],
name = "LintInputs",
srcs = glob(["Source/**/*.swift"]) + [
".swiftlint.yml",
"//Tests:SwiftLintFrameworkTestsData",
],
visibility = ["//Tests:__subpackages__"],
)
filegroup(
name = "SourceFilesToLint",
srcs = glob(["Source/**"]),
visibility = ["//Tests:__subpackages__"],
# Release
genrule(
name = "release",
srcs = [
"//:BUILD",
"//:LICENSE",
"//:LintInputs",
"//Tests:BUILD",
"//bazel:BazelDirectorySources",
],
outs = ["bazel.tar.gz"],
cmd = """
set -euo pipefail
COPYFILE_DISABLE=1 tar czvfh $(OUTS) --exclude ^bazel-out/ --exclude ^external/ *
""",
)
# Xcode Integration
xcodeproj(
name = "xcodeproj",
build_mode = "bazel",

View File

@ -138,7 +138,12 @@ package: build
--version "$(VERSION_STRING)" \
"$(OUTPUT_PACKAGE)"
release: package portable_zip spm_artifactbundle_macos zip_linux_release
bazel_release:
bazel build :release
mv bazel-bin/bazel.tar.gz .
shasum -a 256 bazel.tar.gz > bazel.tar.gz.sha256
release: bazel_release package portable_zip spm_artifactbundle_macos zip_linux_release
docker_image:
docker build --platform linux/amd64 --force-rm --tag swiftlint .

View File

@ -17,9 +17,9 @@ For SwiftLint contributors, follow these steps to cut a release:
* Specify the tag you just pushed from the dropdown.
* Set the release title to the new version number & release name.
* Add the changelog section to the release description text box.
* Upload the pkg installer, framework zip, portable zip,
macos artifactbundle zip, and Linux zip you just built
to the GitHub release binaries.
* Upload the bazel tarball & SHA-256 signature, pkg installer,
framework zip, portable zip, macos artifactbundle zip, and Linux zip
you just built to the GitHub release binaries.
* Click "Publish release".
1. Publish to Homebrew and CocoaPods trunk: `make publish`
1. Celebrate. :tada:

View File

@ -1,8 +1,9 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library", "swift_test")
swift_library(
name = "SwiftLintFrameworkTests.library",
testonly = True,
exports_files(["BUILD"])
filegroup(
name = "SwiftLintFrameworkTestsSources",
srcs = glob(
["SwiftLintFrameworkTests/**/*.swift"],
exclude = [
@ -11,6 +12,22 @@ swift_library(
"SwiftLintFrameworkTests/FileNameNoSpaceRuleTests.swift",
],
),
)
filegroup(
name = "SwiftLintFrameworkTestsData",
srcs = glob(
["SwiftLintFrameworkTests/**"],
# Bazel doesn't support paths with spaces in them
exclude = ["SwiftLintFrameworkTests/Resources/FileNameNoSpaceRuleFixtures/**"],
),
visibility = ["//visibility:public"],
)
swift_library(
name = "SwiftLintFrameworkTests.library",
testonly = True,
srcs = [":SwiftLintFrameworkTestsSources"],
module_name = "SwiftLintFrameworkTests",
deps = [
"//:SwiftLintFramework",
@ -19,14 +36,7 @@ swift_library(
swift_test(
name = "SwiftLintFrameworkTests",
data = [
"//:SwiftLintConfig",
"//:SourceFilesToLint",
] + glob(
["SwiftLintFrameworkTests/**"],
# Bazel doesn't support paths with spaces in them
exclude = ["SwiftLintFrameworkTests/Resources/FileNameNoSpaceRuleFixtures/**"],
),
data = ["//:LintInputs"],
visibility = ["//visibility:public"],
deps = [":SwiftLintFrameworkTests.library"],
)

View File

@ -0,0 +1,6 @@
filegroup(
name = "BazelDirectorySources",
srcs = glob(["*"]),
visibility = ["//visibility:public"],
)