-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from dokku/master
Release 0.8.0
- Loading branch information
Showing
12 changed files
with
276 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
machine: | ||
docker_layer_caching: true | ||
steps: | ||
- checkout | ||
- run: | ||
command: | | ||
make version | ||
if [[ "$CIRCLE_BRANCH" == "release" ]]; then | ||
export PACKAGECLOUD_REPOSITORY=dokku/dokku | ||
make .env.docker | ||
fi | ||
- run: make circleci | ||
- run: make build-docker-image | ||
- run: | ||
command: | | ||
make build-in-docker | ||
[[ -d build ]] && sudo chown -R circleci:circleci build | ||
- run: make validate-in-docker | ||
- store_artifacts: | ||
path: build | ||
destination: build | ||
- run: | ||
command: | | ||
if [[ "$CIRCLE_BRANCH" == "release" ]]; then | ||
make release-in-docker | ||
fi | ||
make release-packagecloud-in-docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sshcommand.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM golang:1.12.0-stretch | ||
RUN apt-get update \ | ||
&& apt install apt-transport-https build-essential curl gnupg2 lintian rpm rsync rubygems-integration ruby-dev ruby software-properties-common sudo -qy \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
RUN gem install --no-ri --no-rdoc --quiet rake fpm package_cloud |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,214 @@ | ||
.PHONY: ci-dependencies shellcheck bats install lint unit-tests test build-test-container test-in-docker | ||
SYSTEM := $(shell sh -c 'uname -s 2>/dev/null') | ||
.PHONY: ci-dependencies shellcheck bats install lint unit-tests test | ||
NAME = sshcommand | ||
VERSION = 0.7.0 | ||
EMAIL = [email protected] | ||
MAINTAINER = dokku | ||
MAINTAINER_NAME = Jose Diaz-Gonzalez | ||
REPOSITORY = sshcommand | ||
HARDWARE = $(shell uname -m) | ||
SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]') | ||
BASE_VERSION ?= 0.8.0 | ||
IMAGE_NAME ?= $(MAINTAINER)/$(REPOSITORY) | ||
PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish | ||
|
||
ci-dependencies: shellcheck bats | ||
|
||
shellcheck: | ||
ifneq ($(shell shellcheck --version > /dev/null 2>&1 ; echo $$?),0) | ||
ifeq ($(SYSTEM),Darwin) | ||
brew install shellcheck | ||
ifeq ($(CIRCLE_BRANCH),release) | ||
VERSION ?= $(BASE_VERSION) | ||
DOCKER_IMAGE_VERSION = $(VERSION) | ||
else | ||
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse' | ||
sudo apt-get update && sudo -E apt-get install -y -qq shellcheck | ||
endif | ||
VERSION = $(shell echo "${BASE_VERSION}")build+$(shell git rev-parse --short HEAD) | ||
DOCKER_IMAGE_VERSION = $(shell echo "${BASE_VERSION}")build-$(shell git rev-parse --short HEAD) | ||
endif | ||
|
||
bats: | ||
ifneq ($(shell bats --version > /dev/null 2>&1 ; echo $$?),0) | ||
ifeq ($(SYSTEM),Darwin) | ||
brew install bats | ||
else | ||
sudo mkdir -p /usr/local | ||
git clone https://github.com/sstephenson/bats.git /tmp/bats | ||
cd /tmp/bats && sudo ./install.sh /usr/local | ||
rm -rf /tmp/bats | ||
endif | ||
endif | ||
version: | ||
@sed -i.bak 's/SSHCOMMAND_VERSION=""/SSHCOMMAND_VERSION="$(VERSION)"/' sshcommand && rm sshcommand.bak | ||
@echo "$(CIRCLE_BRANCH)" | ||
@echo "$(VERSION)" | ||
@./sshcommand version | ||
|
||
|
||
define PACKAGE_DESCRIPTION | ||
Turn SSH into a thin client specifically for your app | ||
Simplifies running a single command over SSH, and | ||
manages authorized keys (ACL) and users in order to do so. | ||
endef | ||
|
||
export PACKAGE_DESCRIPTION | ||
|
||
LIST = build release release-packagecloud validate | ||
targets = $(addsuffix -in-docker, $(LIST)) | ||
|
||
.env.docker: | ||
@rm -f .env.docker | ||
@touch .env.docker | ||
@echo "CIRCLE_BRANCH=$(CIRCLE_BRANCH)" >> .env.docker | ||
@echo "GITHUB_ACCESS_TOKEN=$(GITHUB_ACCESS_TOKEN)" >> .env.docker | ||
@echo "IMAGE_NAME=$(IMAGE_NAME)" >> .env.docker | ||
@echo "PACKAGECLOUD_REPOSITORY=$(PACKAGECLOUD_REPOSITORY)" >> .env.docker | ||
@echo "PACKAGECLOUD_TOKEN=$(PACKAGECLOUD_TOKEN)" >> .env.docker | ||
@echo "VERSION=$(VERSION)" >> .env.docker | ||
|
||
build: pre-build | ||
@$(MAKE) build/darwin/$(NAME) | ||
@$(MAKE) build/linux/$(NAME) | ||
@$(MAKE) build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
@$(MAKE) build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm | ||
|
||
build-docker-image: | ||
docker build --rm -q -f Dockerfile.build -t $(IMAGE_NAME):build . | ||
|
||
$(targets): %-in-docker: .env.docker | ||
docker run \ | ||
--env-file .env.docker \ | ||
--rm \ | ||
--volume /var/lib/docker:/var/lib/docker \ | ||
--volume /var/run/docker.sock:/var/run/docker.sock:ro \ | ||
--volume ${PWD}:/src/github.com/$(MAINTAINER)/$(REPOSITORY) \ | ||
--workdir /src/github.com/$(MAINTAINER)/$(REPOSITORY) \ | ||
$(IMAGE_NAME):build make -e $(@:-in-docker=) | ||
|
||
build/darwin/$(NAME): | ||
chmod +x sshcommand | ||
mkdir -p build/darwin | ||
cp -f sshcommand build/darwin/sshcommand | ||
|
||
build/linux/$(NAME): | ||
chmod +x sshcommand | ||
mkdir -p build/linux | ||
cp -f sshcommand build/linux/sshcommand | ||
|
||
build/deb/$(NAME)_$(VERSION)_amd64.deb: build/linux/$(NAME) | ||
chmod 644 LICENSE | ||
export SOURCE_DATE_EPOCH=$(shell git log -1 --format=%ct) \ | ||
&& mkdir -p build/deb \ | ||
&& fpm \ | ||
--architecture amd64 \ | ||
--category admin \ | ||
--description "$$PACKAGE_DESCRIPTION" \ | ||
--input-type dir \ | ||
--license 'MIT License' \ | ||
--maintainer "$(MAINTAINER_NAME) <$(EMAIL)>" \ | ||
--name $(NAME) \ | ||
--output-type deb \ | ||
--package build/deb/$(NAME)_$(VERSION)_amd64.deb \ | ||
--url "https://github.com/$(MAINTAINER)/$(REPOSITORY)" \ | ||
--vendor "" \ | ||
--version $(VERSION) \ | ||
--verbose \ | ||
build/linux/$(NAME)=/usr/bin/$(NAME) \ | ||
LICENSE=/usr/share/doc/$(NAME)/copyright | ||
|
||
build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm: build/linux/$(NAME) | ||
chmod 644 LICENSE | ||
export SOURCE_DATE_EPOCH=$(shell git log -1 --format=%ct) \ | ||
&& mkdir -p build/rpm \ | ||
&& fpm \ | ||
--architecture x86_64 \ | ||
--category admin \ | ||
--description "$$PACKAGE_DESCRIPTION" \ | ||
--input-type dir \ | ||
--license 'MIT License' \ | ||
--maintainer "$(MAINTAINER_NAME) <$(EMAIL)>" \ | ||
--name $(NAME) \ | ||
--output-type rpm \ | ||
--package build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm \ | ||
--rpm-os linux \ | ||
--url "https://github.com/$(MAINTAINER)/$(REPOSITORY)" \ | ||
--vendor "" \ | ||
--version $(VERSION) \ | ||
--verbose \ | ||
build/linux/$(NAME)=/usr/bin/$(NAME) \ | ||
LICENSE=/usr/share/doc/$(NAME)/copyright | ||
|
||
clean: | ||
rm -rf build release validation | ||
|
||
install: | ||
@echo setting up... | ||
cp ./sshcommand /usr/local/bin | ||
chmod +x /usr/local/bin | ||
circleci: | ||
docker version | ||
rm -f ~/.gitconfig | ||
|
||
lint: | ||
bin/gh-release: | ||
mkdir -p bin | ||
curl -o bin/gh-release.tgz -sL https://github.com/progrium/gh-release/releases/download/v2.2.1/gh-release_2.2.1_$(SYSTEM_NAME)_$(HARDWARE).tgz | ||
tar xf bin/gh-release.tgz -C bin | ||
chmod +x bin/gh-release | ||
|
||
release: bin/gh-release | ||
rm -rf release && mkdir release | ||
tar -zcf release/$(NAME)_$(VERSION)_linux_$(HARDWARE).tgz -C build/linux $(NAME) | ||
tar -zcf release/$(NAME)_$(VERSION)_darwin_$(HARDWARE).tgz -C build/darwin $(NAME) | ||
cp build/deb/$(NAME)_$(VERSION)_amd64.deb release/$(NAME)_$(VERSION)_amd64.deb | ||
cp build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm release/$(NAME)-$(VERSION)-1.x86_64.rpm | ||
bin/gh-release create $(MAINTAINER)/$(REPOSITORY) $(VERSION) $(shell git rev-parse --abbrev-ref HEAD) | ||
|
||
release-packagecloud: | ||
@$(MAKE) release-packagecloud-deb | ||
@$(MAKE) release-packagecloud-rpm | ||
|
||
release-packagecloud-deb: build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/trusty build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/utopic build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/vivid build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/wily build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/xenial build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/yakkety build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/zesty build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/artful build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/bionic build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/wheezy build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/jessie build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/stretch build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/buster build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
|
||
release-packagecloud-rpm: build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm | ||
package_cloud push $(PACKAGECLOUD_REPOSITORY)/el/7 build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm | ||
|
||
validate: test | ||
mkdir -p validation | ||
lintian build/deb/$(NAME)_$(VERSION)_amd64.deb || true | ||
dpkg-deb --info build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
dpkg -c build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
cd validation && rpm2cpio ../build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm > $(NAME)-$(VERSION)-1.x86_64.cpio | ||
ls -lah build/deb build/rpm validation | ||
sha1sum build/deb/$(NAME)_$(VERSION)_amd64.deb | ||
sha1sum build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm | ||
|
||
test: lint unit-tests | ||
|
||
lint: shellcheck bats | ||
@echo linting... | ||
# SC2034: VAR appears unused - https://github.com/koalaman/shellcheck/wiki/SC2034 | ||
# desc is used to declare the description of the function | ||
@$(QUIET) find . -not -path '*/\.*' | xargs file | egrep "shell|bash" | awk '{ print $$1 }' | sed 's/://g' | xargs shellcheck -e SC2034 | ||
|
||
unit-tests: | ||
unit-tests: /usr/local/bin/sshcommand | ||
@echo running unit tests... | ||
@$(QUIET) bats tests/unit | ||
@mkdir -p test-results/bats | ||
@$(QUIET) TERM=linux bats --formatter bats-format-junit -e -T -o test-results/bats tests/unit | ||
|
||
test: lint unit-tests | ||
pre-build: | ||
true | ||
|
||
build-test-container: | ||
@echo building test container... | ||
docker build -t sshcommand_test -f Dockerfile.test . | ||
/usr/local/bin/sshcommand: | ||
@echo installing sshcommand | ||
cp ./sshcommand /usr/local/bin/sshcommand | ||
chmod +x /usr/local/bin/sshcommand | ||
|
||
test-in-docker: | ||
ifneq ($(shell docker inspect sshcommand_test > /dev/null 2>&1 ; echo $$?),0) | ||
$(MAKE) build-test-container | ||
shellcheck: | ||
ifneq ($(shell shellcheck --version >/dev/null 2>&1 ; echo $$?),0) | ||
ifeq ($(SYSTEM_NAME),darwin) | ||
brew install shellcheck | ||
else | ||
sudo apt-get update -qq && sudo apt-get install -qq -y shellcheck | ||
endif | ||
endif | ||
docker run -ti --rm -v ${PWD}:/app -w /app --hostname='box223' sshcommand_test make ci-dependencies install test | ||
|
||
deps: | ||
go get -u github.com/progrium/gh-release/... | ||
|
||
release: deps | ||
rm -rf release && mkdir release | ||
tar -zcf release/$(NAME)_$(VERSION).tgz . | ||
gh-release create dokku/$(NAME) $(VERSION) \ | ||
$(shell git rev-parse --abbrev-ref HEAD) v$(VERSION) | ||
bats: | ||
ifeq ($(SYSTEM_NAME),darwin) | ||
ifneq ($(shell bats --version >/dev/null 2>&1 ; echo $$?),0) | ||
brew install bats-core | ||
endif | ||
else | ||
git clone https://github.com/josegonzalez/bats-core.git /tmp/bats | ||
cd /tmp/bats && sudo ./install.sh /usr/local | ||
rm -rf /tmp/bats | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.