Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build RPM for peridot cli #169

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
13 changes: 13 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ load("//:repositories.bzl", "go_repositories")

go_rules_dependencies()

http_archive(
name = "rules_pkg",
urls = [
"https://github.com/bazelbuild/rules_pkg/releases/download/0.10.1/rules_pkg-0.10.1.tar.gz",
],
sha256 = "d250924a2ecc5176808fc4c25d5cf5e9e79e6346d79d5ab1c493e289e722d1d0",
)
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()

load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
find_system_rpmbuild(name="rules_pkg_rpmbuild")

go_register_toolchains(
nogo = "@peridot//:nogo",
version = "1.22.2",
Expand Down
33 changes: 33 additions & 0 deletions peridot/cmd/v1/peridot/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

load(
"@rules_pkg//pkg:mappings.bzl",
"pkg_attributes",
"pkg_files",
)
load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")

go_library(
name = "peridot_lib",
srcs = [
Expand All @@ -20,6 +27,9 @@ go_library(
data = [
"//peridot/proto/v1:client_go",
],
x_defs = {
"Version": "{STABLE_BUILD_TAG}",
},
importpath = "peridot.resf.org/peridot/cmd/v1/peridot",
visibility = ["//visibility:private"],
deps = [
Expand All @@ -37,3 +47,26 @@ go_binary(
embed = [":peridot_lib"],
visibility = ["//visibility:public"],
)

pkg_files(
name = "peridot-files",
srcs = [":peridot"],
attributes = pkg_attributes(
user = "root",
group = "root",
mode = "0755",
),
prefix = "/usr/bin"
)

pkg_rpm(
name = "peridot-cli",
srcs = [":peridot-files"],
license = "MIT",
summary = "Peridot Command Line Interface",
version = "0.2.0",
release = "0",
architecture = "x86_64",
description = "A command line interface to interact with the Peridot build system",
source_date_epoch = 0,
)
10 changes: 7 additions & 3 deletions peridot/cmd/v1/peridot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@
package main

import (
"log"
"strings"

"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"log"
"strings"
)

var Version = "[unknown]"

var root = &cobra.Command{
Use: "peridot",
Use: "peridot",
Version: Version,
}

func init() {
Expand Down