Skip to content

Commit

Permalink
Enable bzlmod support
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeykhliustin committed May 1, 2024
1 parent ef2f994 commit f19b59e
Show file tree
Hide file tree
Showing 17 changed files with 182 additions and 134 deletions.
6 changes: 3 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
startup --output_base=./bazel-output-base

common --enable_bzlmod

build --announce_rc
build --spawn_strategy=local
build --strategy=SwiftCompile=worker
build --verbose_failures
build --compilation_mode=fastbuild
build --experimental_multi_threaded_digest
build --verbose_failures
build:rules_xcodeproj --xcode_version_config=@local_config_xcode//:host_xcodes

common:ci --isatty=1
common:ci --terminal_columns=127

import %workspace%/.env_bazelrc
try-import %workspace%/.env_bazelrc
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.5.0
7.1.1
15 changes: 15 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"homepage": "https://github.com/sergeykhliustin/BazelPods",
"maintainers": [
{
"email": "[email protected]",
"github": "sergeykhliustin",
"name": "Sergii Khliustin"
}
],
"repository": [
"github:sergeykhliustin/BazelPods"
],
"versions": [],
"yanked_versions": {}
}
12 changes: 12 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
matrix:
bazel: ["6.x", "7.x"]
platform: ["macos_arm64", "macos"]
tasks:
verify_build:
name: Verify Build
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- "@bazelpods//:bazelpods"
build_flags:
- "--enable_bzlmod"
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/release.tar.gz"
}
60 changes: 27 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Get latest release tag
id: latesttag
run: |
CURRENT_VERSION=$(gh release list --limit 1 --json version | jq .[0].tagName | tr -d '"')
CURRENT_VERSION=$(gh release list --limit 1 --json tagName | jq .[0].tagName | tr -d '"')
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
- name: Validate new version
Expand All @@ -33,44 +33,38 @@ jobs:
- name: Archive sources
run: |
tar czvf release.tar.gz Sources BUILD repositories.bzl
tar czvf release.tar.gz Sources BUILD.bazel repositories.bzl MODULE.bazel
- name: Calculate SHA256
run: |
echo "SHA256=$(shasum -a 256 release.tar.gz | cut -d ' ' -f 1)" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
## Workspace Snippet
```starlark
http_archive(
name = "bazelpods",
sha256 = "${{ env.SHA256 }}",
url = "https://github.com/sergeykhliustin/BazelPods/releases/download/${{ env.NEW_VERSION }}/release.tar.gz"
)
load("@bazelpods//:repositories.bzl", "bazelpods_dependencies")
run: |
set -euo pipefail
bazelpods_dependencies()
```
draft: true
prerelease: false
git config user.name "Release Workflow"
git config user.email "[email protected]"
- name: Upload Release Asset
id: upload_release_asset
uses: actions/upload-release-asset@v1
gh release create "${{ github.ref }}" \
--title "${{ env.NEW_VERSION }}" \
--target "$GITHUB_SHA" \
--generate-notes \
--prerelease \
--notes "### Bzlmod Snippet
\`\`\`starlark
bazel_dep(name = \"bazelpods\", version = \"${{ env.NEW_VERSION }}\")
\`\`\`
## Workspace Snippet
\`\`\`starlark
http_archive(
name = \"bazelpods\",
sha256 = \"${{ env.SHA256 }}\",
url = \"https://github.com/sergeykhliustin/BazelPods/releases/download/${{ env.NEW_VERSION }}/release.tar.gz\"
)
load(\"@bazelpods//:repositories.bzl\", \"bazelpods_dependencies\")
bazelpods_dependencies()
\`\`\`" \
"release.tar.gz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release.tar.gz
asset_name: release.tar.gz
asset_content_type: application/gzip
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Tests/Podfile
Tests/Podfile.lock
Tests/Pods
.env_bazelrc
MODULE.bazel.lock
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby 3.3.1
4 changes: 2 additions & 2 deletions BUILD → BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ swift_library(
"Sources/BazelPods/**/*.swift",
"Sources/Shared/**/*.swift"
]),
deps = [":BazelPodsCore", ":Logger", "@bazelpods-swift-argument-parser//:ArgumentParser"],
deps = [":BazelPodsCore", ":Logger", "@bazelpods_swift_argument_parser//:ArgumentParser"],
copts = ["-swift-version", SWIFT_VERSION]
)

Expand Down Expand Up @@ -65,6 +65,6 @@ swift_library(
"Sources/Analyzer/**/*.swift",
"Sources/Shared/**/*.swift"
]),
deps = [":BazelPodsCore", ":Logger", "@bazelpods-swift-argument-parser//:ArgumentParser"],
deps = [":BazelPodsCore", ":Logger", "@bazelpods_swift_argument_parser//:ArgumentParser"],
copts = ["-swift-version", SWIFT_VERSION],
)
40 changes: 40 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module(
name = "bazelpods",
version = "0.0.0",
compatibility_level = 1,
bazel_compatibility = [">=6.0.0"],
repo_name = "bazelpods"
)

bazel_dep(
name = "apple_support",
version = "1.15.1",
repo_name = "build_bazel_apple_support",
)
bazel_dep(
name = "rules_apple",
version = "3.5.1",
repo_name = "build_bazel_rules_apple",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
)
bazel_dep(
name = "rules_swift",
version = "1.18.0",
repo_name = "build_bazel_rules_swift",
)
bazel_dep(
name = "rules_ios",
version = "4.4.0",
repo_name = "build_bazel_rules_ios"
)

non_module_deps = use_extension(
"//:repositories.bzl",
"non_module_deps",
)
use_repo(non_module_deps, "bazelpods_swift_argument_parser")

bazel_dep(name = "rules_xcodeproj", version = "2.2.0")
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ Core idea, Podspec parser, Starlark compiler are forked from [PodToBUILD](https:
### 🎸 Let's rock
Don't forget to setup [`rules_ios`](https://github.com/bazel-ios/rules_ios) and [`rules_apple`](https://github.com/bazelbuild/rules_apple) first.

Add `BazelPods` to your `MODULE.bazel`
```starlark
bazel_dep(name = "bazelpods", version = "<version>")
```

Add `BazelPods` to your `WORKSPACE`
```starlark
http_archive(
Expand Down
3 changes: 3 additions & 0 deletions TestTools/Pods.json
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,9 @@
"SwiftyDropboxObjC": {
"version": "10.0.1"
},
"SwiftyGif": {
"version": "5.4.5"
},
"TABAnimated": {
"version": "2.6.5"
},
Expand Down
61 changes: 60 additions & 1 deletion Tests/Recorded/SwiftyGif/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 0 additions & 64 deletions WORKSPACE

This file was deleted.

Empty file added WORKSPACE.bzlmod
Empty file.
Loading

0 comments on commit f19b59e

Please sign in to comment.