Skip to content
Open
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
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.4.2
13 changes: 13 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"homepage": "https://github.com/skydio/revup",
"maintainers": [
{
"email": "jerry@skydio.com",
"github": "skydio",
"name": "Jerry Zhang"
}
],
"repository": ["github:skydio/revup"],
"versions": [],
"yanked_versions": {}
}
11 changes: 11 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
matrix:
platform: ["debian11", "macos", "ubuntu2004"]
bazel: ["8.x"]

tasks:
verify_targets:
name: Build the revup wheel
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- "@revup//:revup"
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"url": "https://github.com/skydio/revup/releases/download/v{VERSION}/revup-v{VERSION}.tar.gz",
"integrity": "**leave this alone**",
"strip_prefix": "revup-{VERSION}"
}
Binary file added .coverage
Binary file not shown.
25 changes: 25 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Bazel build

on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]

jobs:
build:
runs-on: ubuntu-latest
name: bazel build //:revup
steps:
- name: Install pandoc
run: sudo apt-get install -y pandoc
- uses: actions/checkout@v4
name: Checkout the repo
- uses: bazel-contrib/setup-bazel@0.9.1
name: Set up Bazel
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build the revup wheel
run: bazel build //:revup
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ build/
revup.egg-info/
revup/man1/
__pycache__
bazel-*
MODULE.bazel.lock
197 changes: 197 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
load("@rules_license//rules:license.bzl", "license")
load("@rules_python//python:defs.bzl", "py_library")
load("@rules_python//python:packaging.bzl", "py_package", "py_wheel")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load(":version.bzl", "REVUP_VERSION")

package(default_applicable_licenses = [":license"])

license(
name = "license",
package_name = "revup",
license_kinds = ["@rules_license//licenses/spdx:MIT"],
license_text = "LICENSE",
)

REVUP_DATE = "Apr 21, 2021"

REVUP_VERSION_HASH = "main"

# Man page sources, one per docs/*.md.
MAN_PAGES = [
"amend",
"cherry-pick",
"config",
"restack",
"revup",
"upload",
]

# Driver script that takes (name, version, date, input.md, output.1.gz) and
# emits the gzipped man page. Honors $M4 / $PANDOC env vars supplied below
# so the action runs hermetically off the prebuilt rules_m4 / pandoc archives.
sh_binary(
name = "build_manpage",
srcs = ["scripts/build_manpage.sh"],
)

# Per-platform config settings used to pick a pandoc binary.
[
config_setting(
name = "is_{}_{}".format(os, cpu),
constraint_values = [
"@platforms//os:{}".format(os),
"@platforms//cpu:{}".format(cpu),
],
)
for os, cpu in [
("linux", "x86_64"),
("linux", "arm64"),
("macos", "x86_64"),
("macos", "arm64"),
("windows", "x86_64"),
]
]

# Per-platform pandoc binary, fetched in MODULE.bazel.
alias(
name = "pandoc",
actual = select({
":is_linux_x86_64": "@pandoc_linux_amd64//:bin/pandoc",
":is_linux_arm64": "@pandoc_linux_arm64//:bin/pandoc",
":is_macos_x86_64": "@pandoc_macos_amd64//:bin/pandoc",
":is_macos_arm64": "@pandoc_macos_arm64//:bin/pandoc",
":is_windows_x86_64": "@pandoc_windows_amd64//:pandoc.exe",
}),
)

# Generate revup/man1/<name>.1.gz from docs/<name>.md. Uses a genrule (rather
# than run_binary) so that the m4 make-variable from rules_m4's toolchain
# expands correctly.
[
genrule(
name = "man1_{}".format(page),
srcs = ["docs/{}.md".format(page)],
outs = ["revup/man1/{}.1.gz".format(page)],
cmd = (
"M4=$(M4) PANDOC=$(execpath :pandoc) " +
"$(execpath :build_manpage) " +
"{page} {version} '{date}' $(SRCS) $@"
).format(
date = REVUP_DATE,
page = page,
version = REVUP_VERSION,
),
tools = [
":build_manpage",
":pandoc",
],
toolchains = ["@rules_m4//m4:current_m4_toolchain"],
)
for page in MAN_PAGES
]

filegroup(
name = "man1",
srcs = ["revup/man1/{}.1.gz".format(page) for page in MAN_PAGES],
)

# Rewrite docs/images/* links in README.md to absolute GitHub URLs, matching
# the substitution that setup.py performs at sdist build time.
genrule(
name = "long_description",
srcs = ["README.md"],
outs = ["README.pypi.md"],
cmd = """\
python3 - "$<" "$@" <<'PY'
import re, sys
src, dst = sys.argv[1], sys.argv[2]
text = open(src).read()
text = re.sub(
r"<!--\\s*PYPI_REMOVE\\s*-->((?!PYPI_REMOVE).)*<!--\\s*/PYPI_REMOVE\\s*-->",
"",
text,
flags=re.MULTILINE | re.DOTALL,
)
text = text.replace(
"docs/images/",
"https://raw.githubusercontent.com/skydio/revup/{hash}/docs/images/",
)
open(dst, "w").write(text)
PY
""".format(hash = REVUP_VERSION_HASH),
)

py_library(
name = "revup_lib",
srcs = glob(["revup/**/*.py"]),
data = [":man1"],
imports = ["."],
visibility = ["//visibility:public"],
)

py_package(
name = "revup_pkg",
packages = ["revup"],
deps = [":revup_lib"],
)

py_wheel(
name = "revup",
abi = "none",
author = "Jerry Zhang",
author_email = "jerry@skydio.com",
classifiers = [
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Version Control",
"Topic :: Software Development :: Version Control :: Git",
"Programming Language :: Python",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3 :: Only",
"Environment :: Console",
"Typing :: Typed",
],
description_content_type = "text/markdown",
description_file = ":long_description",
distribution = "revup",
entry_points = {
"console_scripts": ["revup = revup.__main__:_main"],
},
extra_distinfo_files = {
"//:LICENSE": "LICENSE",
},
homepage = "https://github.com/skydio/revup",
license = "MIT",
platform = "any",
project_urls = {
"Source": "https://github.com/skydio/revup",
"Bug Tracker": "https://github.com/skydio/revup/issues",
},
python_requires = ">=3.10",
python_tag = "py3",
requires = [
"aiohttp",
"argcomplete",
"async_lru",
"attrs",
"requests",
"rich",
"multidict",
"yarl",
"async_timeout",
"charset_normalizer",
"aiosignal",
],
summary = "Revolutionary github tools. Effortlessly create multiple branches and pull requests.",
version = REVUP_VERSION,
visibility = ["//visibility:public"],
deps = [":revup_pkg"],
)
74 changes: 74 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
module(
name = "revup",
# Keep this in sync with revup/version.py REVUP_VERSION. MODULE.bazel does
# not support `load`, so the value cannot be imported from version.bzl.
version = "0.4.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_m4", version = "0.3.bcr.1")
bazel_dep(name = "rules_python", version = "0.36.0")
bazel_dep(name = "rules_shell", version = "0.3.0")

# Pandoc isn't on BCR, so we fetch the official prebuilt binaries directly.
# One http_archive per (os, arch); BUILD.bazel selects the right one.
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

PANDOC_VERSION = "3.10"

_PANDOC_BUILD = """\
exports_files(["bin/pandoc"], visibility = ["//visibility:public"])
"""

_PANDOC_WINDOWS_BUILD = """\
exports_files(["pandoc.exe"], visibility = ["//visibility:public"])
"""

http_archive(
name = "pandoc_linux_amd64",
url = "https://github.com/jgm/pandoc/releases/download/{v}/pandoc-{v}-linux-amd64.tar.gz".format(v = PANDOC_VERSION),
sha256 = "e0f8af62d0f267d22baa5bcefe6d5dda3a097ccc60de794b759fe03159923244",
strip_prefix = "pandoc-{}".format(PANDOC_VERSION),
build_file_content = _PANDOC_BUILD,
)

http_archive(
name = "pandoc_linux_arm64",
url = "https://github.com/jgm/pandoc/releases/download/{v}/pandoc-{v}-linux-arm64.tar.gz".format(v = PANDOC_VERSION),
sha256 = "55413dfb0c1aec861641fe858f1f73e84848f3db497b1c0c02e62887ea76f4a4",
strip_prefix = "pandoc-{}".format(PANDOC_VERSION),
build_file_content = _PANDOC_BUILD,
)

http_archive(
name = "pandoc_macos_amd64",
url = "https://github.com/jgm/pandoc/releases/download/{v}/pandoc-{v}-x86_64-macOS.zip".format(v = PANDOC_VERSION),
sha256 = "6334f4d9af7c9e37e761dfad56fa5507685f6d29724ebf31c4be6d5c654a3161",
strip_prefix = "pandoc-{}-x86_64".format(PANDOC_VERSION),
build_file_content = _PANDOC_BUILD,
)

http_archive(
name = "pandoc_macos_arm64",
url = "https://github.com/jgm/pandoc/releases/download/{v}/pandoc-{v}-arm64-macOS.zip".format(v = PANDOC_VERSION),
sha256 = "d9cad01d96ae774a0dc8c8c45bb1ad3e4c5ff2cc2e24f45958f5f9b7974aee34",
strip_prefix = "pandoc-{}-arm64".format(PANDOC_VERSION),
build_file_content = _PANDOC_BUILD,
)

http_archive(
name = "pandoc_windows_amd64",
url = "https://github.com/jgm/pandoc/releases/download/{v}/pandoc-{v}-windows-x86_64.zip".format(v = PANDOC_VERSION),
sha256 = "bb808d00fd58762299d64582a9b4c3e4b106cd929e62c5f19bcdcb496f1e54ae",
strip_prefix = "pandoc-{}".format(PANDOC_VERSION),
build_file_content = _PANDOC_WINDOWS_BUILD,
)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
is_default = True,
python_version = "3.12",
)
24 changes: 6 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ clean:
rm -rf $(BUILD_DIR)
rm -rf .mypy_cache

REVUP_VERSION:=$(shell $(PYTHON) revup/__init__.py)
REVUP_VERSION:=$(shell $(PYTHON) revup/version.py)
REVUP_DATE ?= Apr 21, 2021
define REVUP_HEADER
---
title: TITLE
section: 1
header: Revup Manual
footer: revup VERSION
date: DATE
---
endef
export REVUP_HEADER

REVUP_VERSION_HASH?=${shell git rev-parse --short v$(REVUP_VERSION) || echo main}

Expand All @@ -66,13 +56,11 @@ upload:
$(PYTHON) -m twine upload build/revup-$(REVUP_VERSION).tar.gz

man:
mkdir -p revup/man1 ; \
cd docs ; \
for file in *.md ; do \
CMD_NAME=`echo $${file} | awk -F'[.]' '{print $$1}'` ; \
echo "$${REVUP_HEADER}" | m4 -DTITLE=$${CMD_NAME} -DVERSION=$(REVUP_VERSION) -DDATE="$(REVUP_DATE)" - | \
cat - $${file} | pandoc -f markdown-smart -s -t man > ../revup/man1/$${CMD_NAME}.1 || exit 1 ; \
gzip -n -f -k ../revup/man1/$${CMD_NAME}.1 || exit 1 ; \
mkdir -p revup/man1
@for src in docs/*.md ; do \
name=$$(basename $${src} .md) ; \
scripts/build_manpage.sh "$${name}" "$(REVUP_VERSION)" "$(REVUP_DATE)" \
"$${src}" "revup/man1/$${name}.1.gz" || exit 1 ; \
done

test:
Expand Down
5 changes: 0 additions & 5 deletions revup/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
__version__ = "0.4.0"

if __name__ == "__main__":
# So that Makefile can get the version without having to parse python
print(__version__)
Loading
Loading