Skip to content
Snippets Groups Projects
Unverified Commit e568cb6a authored by Carlos Tadeu Panato Junior's avatar Carlos Tadeu Panato Junior Committed by GitHub
Browse files

use go modules to track tools (#395)


Signed-off-by: default avatarCarlos Panato <ctadeu@gmail.com>
parent 4347b0b9
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,10 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "gomod"
directory: "./hack/tools"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
......
......@@ -9,4 +9,4 @@ logid
/server
swagger
dist/*
hack/*
hack/tools/bin/*
......@@ -23,8 +23,6 @@ SRCS = $(shell find cmd -iname "*.go") $(shell find pkg -iname "*.go"|grep -v pk
TOOLS_DIR := hack/tools
TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)
BIN_DIR := $(abspath $(ROOT_DIR)/bin)
GO_INSTALL = ./scripts/go_install.sh
# Set version variables for LDFLAGS
GIT_VERSION ?= $(shell git describe --tags --always --dirty)
......@@ -43,9 +41,7 @@ ifeq ($(DIFF), 1)
endif
# Binaries
SWAGGER_VER := v0.27.0
SWAGGER_BIN := swagger
SWAGGER := $(TOOLS_BIN_DIR)/$(SWAGGER_BIN)-$(SWAGGER_VER)
SWAGGER := $(TOOLS_BIN_DIR)/swagger
CLI_PKG=github.com/sigstore/rekor/cmd/rekor-cli/app
CLI_LDFLAGS="-X $(CLI_PKG).gitVersion=$(GIT_VERSION) -X $(CLI_PKG).gitCommit=$(GIT_HASH) -X $(CLI_PKG).gitTreeState=$(GIT_TREESTATE) -X $(CLI_PKG).buildDate=$(BUILD_DATE)"
......@@ -84,7 +80,7 @@ test:
clean:
rm -rf dist
rm -rf hack/tools
rm -rf hack/tools/bin
rm -rf rekor-cli rekor-server
clean-gen: clean
......@@ -128,9 +124,10 @@ dist-server:
.PHONY: dist
dist: dist-server dist-cli
## --------------------------------------
## Tooling Binaries
## --------------------------------------
$(SWAGGER): ## Build swagger from tools folder.
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) github.com/go-swagger/go-swagger/cmd/swagger $(SWAGGER_BIN) $(SWAGGER_VER)
$(SWAGGER): $(TOOLS_DIR)/go.mod
cd $(TOOLS_DIR); go build -tags=tools -o $(TOOLS_BIN_DIR)/swagger github.com/go-swagger/go-swagger/cmd/swagger
module github.com/sigstore/rekor/hack/tools
go 1.16
require github.com/go-swagger/go-swagger v0.27.0
This diff is collapsed.
// +build tools
// Copyright 2021 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// This package imports things required by build scripts, to force `go mod` to see them as dependencies
package tools
import (
_ "github.com/go-swagger/go-swagger/cmd/swagger"
)
#!/usr/bin/env bash
# Copyright 2020 The Sigstore Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -o errexit
set -o nounset
set -o pipefail
if [ -z "${1}" ]; then
echo "must provide module as first parameter"
exit 1
fi
if [ -z "${2}" ]; then
echo "must provide binary name as second parameter"
exit 1
fi
if [ -z "${3}" ]; then
echo "must provide version as third parameter"
exit 1
fi
if [ -z "${GOBIN}" ]; then
echo "GOBIN is not set. Must set GOBIN to install the bin in a specified directory."
exit 1
fi
tmp_dir=$(mktemp -d -t goinstall_XXXXXXXXXX)
function clean {
rm -rf "${tmp_dir}"
}
trap clean EXIT
rm "${GOBIN}/${2}"* || true
cd "${tmp_dir}"
# create a new module in the tmp directory
go mod init fake/mod
# install the golang module specified as the first argument
go get -tags tools "${1}@${3}"
mv "${GOBIN}/${2}" "${GOBIN}/${2}-${3}"
ln -sf "${GOBIN}/${2}-${3}" "${GOBIN}/${2}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment