Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
matrix:
# If `Windows` support is removed - state so inthe README.md
os: [ubuntu-latest, macos-latest, windows-latest]
bazel_mode: [bzlmod, workspace, both]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -31,11 +30,8 @@ jobs:
# Share repository cache between workflows.
repository-cache: true
- name: Built & Test
env:
BZLMOD: ${{ matrix.bazel_mode != 'workspace' && '--enable_bzlmod' || '--noenable_bzlmod' }}
WORKSPACE: ${{ matrix.bazel_mode != 'bzlmod' && '--enable_workspace' || '--noenable_workspace' }}
run: |
bazel test ${{env.BZLMOD}} ${{env.WORKSPACE}} //...
bazel test //...

# Single aggregating gate for branch protection. It depends on every job that
# must pass, so "done" is the only status check that needs to be marked
Expand Down
36 changes: 15 additions & 21 deletions .github/workflows/release_prep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function die() {
# Custom args to update as needed.
PACKAGE_NAME="bzl"
BAZELMOD_NAME="helly25_bzl"
WORKSPACE_NAME="helly25_bzl"
PATCHES=()

# Automatic vars from workflow integration.
Expand All @@ -40,8 +39,8 @@ if [[ "${TAG}" == "v${VERSION}" ]]; then
fi

# Computed vars.
PREFIX="${PACKAGE_NAME}-${TAG}" # Internal archive root directory folder: bzl-0.4.0
ARCHIVE="${PACKAGE_NAME}-${TAG}.tar.gz" # Target asset name on GitHub: bzl-0.4.0.tar.gz
PREFIX="${PACKAGE_NAME}-${TAG}" # Internal archive root directory folder: bzl-0.5.0
ARCHIVE="${PACKAGE_NAME}-${TAG}.tar.gz" # Target asset name on GitHub: bzl-0.5.0.tar.gz

BAZELMOD_VERSION="$(sed -rne 's,.*version = "([0-9]+([.][0-9]+)+.*)".*,\1,p' <MODULE.bazel | head -n1)"
CHANGELOG_VERSION="$(sed -rne 's,^# ([0-9]+([.][0-9]+)+.*)$,\1,p' <CHANGELOG.md | head -n1)"
Expand All @@ -64,7 +63,7 @@ fi
} >BUILD.bazel

# Apply patches
for patch in "${PATCHES[@]}"; do
for patch in ${PATCHES[@]+"${PATCHES[@]}"}; do
patch -s -p 1 <"${patch}"
done

Expand All @@ -85,10 +84,18 @@ EXCLUDES=(
done
} >>.gitattributes

# Build the archive directly out into the parent repo workspace root folder path
git archive --format=tar.gz --prefix="${PREFIX}/" "${TAG}" -o "${ARCHIVE}" --add-virtual-file="${PREFIX}/VERSION:${VERSION}" --worktree-attributes

SHA256="$(shasum -a 256 "${ARCHIVE}" | awk '{print $1}')"
# Build the archive from the patched/generated worktree, not the committed
# "${TAG}" tree: `git archive "${TAG}"` reads the commit and would silently drop
# the edits above (any patches, the generated BUILD.bazel). Stage the worktree
# into a THROWAWAY index so the real index/checkout is never touched (nothing to
# undo afterwards), and archive that tree. export-ignore still applies via the
# staged .gitattributes (+ --worktree-attributes).
TMP_INDEX="$(mktemp -u)"
GIT_INDEX_FILE="${TMP_INDEX}" git read-tree HEAD
GIT_INDEX_FILE="${TMP_INDEX}" git add --all
ARCHIVE_TREE="$(GIT_INDEX_FILE="${TMP_INDEX}" git write-tree)"
rm -f "${TMP_INDEX}"
git archive --format=tar.gz --prefix="${PREFIX}/" -o "${ARCHIVE}" --add-virtual-file="${PREFIX}/VERSION:${VERSION}" --worktree-attributes "${ARCHIVE_TREE}"

# Print header
echo "# Version ${VERSION}"
Expand All @@ -103,17 +110,4 @@ cat <<EOF
\`\`\`
bazel_dep(name = "${BAZELMOD_NAME}", version = "${VERSION}")
\`\`\`

## For Bazel WORKSPACE

\`\`\`
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "${WORKSPACE_NAME}",
url = "https://github.com/helly25/${PACKAGE_NAME}/releases/download/${TAG}/${ARCHIVE}",
sha256 = "${SHA256}",
strip_prefix = "${PREFIX}",
)
\`\`\`
EOF
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# 0.4.5
# 0.5.0

- [BC] Dropped legacy `WORKSPACE` support; the module is now bzlmod-only.

# 0.4.4

- Re-release of `0.4.3` with no functional changes (release/CI tooling only).

# 0.4.3

- Added `paths.ensure_trailing_slash` and `paths.ensure_trailing_slash_windows` to append a single trailing separator, handling roots and existing trailing separators. An optional `default_if_empty` controls the fallback for empty input (e.g. `"/"` to anchor at the platform root).
Expand Down
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module(
name = "helly25_bzl",
version = "0.4.5",
version = "0.5.0",
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,18 @@ Provides:

## Installation

The library is available for both Bazelmod and Workspace installations and works
on MacOS, Ubuntu and Windows with Bazel version 7.x and 8.x (Other systems are
simply not tested). However future version may drop Windows support.
The library is available as a Bazel module (bzlmod) and works on MacOS, Ubuntu
and Windows with Bazel version 7.x and 8.x (Other systems are simply not tested).
However future version may drop Windows support.

### For MODULES.bazel
### For MODULE.bazel

See [helly25/bzl/releases](https://github.com/helly25/bzl/releases) to replace the version number.

```starlark
bazel_dep(name = "helly25_bzl", version = "0.0.0")
```

### For WORKSPACE

```bazel
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "helly25_bzl",
url = "https://github.com/helly25/bzl/releases/download/0.0.0/bzl-0.0.0.tar.gz",
sha256 = "...." # see https://github.com/helly25/bzl/releases for version numbers SHA256 codes.
)
```

### Dependencies

- `bazel_skylib`.
31 changes: 0 additions & 31 deletions WORKSPACE

This file was deleted.

Loading