Skip to content

Commit

Permalink
Merge pull request #59 from gliderlabs/master
Browse files Browse the repository at this point in the history
Release 0.7.0
  • Loading branch information
josegonzalez authored Oct 28, 2021
2 parents f89da93 + 006e2d6 commit 7a0409c
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 75 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Dockerfile*
LICENSE
README.md
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: CI

on:
pull_request:
branches:
- '*'
push:
branches:
- 'master'
- 'release'

jobs:
build:
name: build
runs-on: ubuntu-18.04
strategy:
fail-fast: true
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

steps:
- uses: actions/checkout@v2
- name: make version
run: |
make version .env.docker
- run: make ci-report
- run: make build-docker-image
- run: make build-in-docker
- run: make validate-in-docker
- name: upload packages
uses: actions/upload-artifact@v2
with:
name: build
path: build/**/*
- name: make release-in-docker
run: |
if [[ "${GITHUB_REF#refs/heads/}" == "release" ]]; then
export CI_BRANCH=${GITHUB_REF#refs/heads/}
export PACKAGECLOUD_REPOSITORY=dokku/dokku
rm .env.docker
make .env.docker release-in-docker release-packagecloud-in-docker
fi
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,3 @@ validation/*

# .env files
.env*

build
site
18 changes: 8 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# Change Log
All notable changes to this project will be documented in this file.

## [Unreleased][unreleased]
## [v0.7.0](https://github.com/gliderlabs/registrator/compare/v0.6.0...v0.7.0) - 2020-10-28

### Fixed

- #56 @0xflotus Fix typo in readme

### Added

### Removed
- #58: @josegonzalez Add arm support
- #57: @adam12 Add bullseye to deb release task

### Changed

## [v0.6.0] - 2020-05-06
## [v0.6.0](https://github.com/gliderlabs/registrator/compare/v0.5.0...v0.6.0) - 2020-05-06

### Added

- #53: @josegonzalez Release packages for Focal Fossa

## [v0.5.0] - 2020-03-13
## [v0.5.0](https://github.com/gliderlabs/registrator/compare/v0.4.0...v0.5.0) - 2020-03-13
### Fixed

- #19: @stormcat24 Use correct protocol for download url
Expand All @@ -37,7 +39,3 @@ All notable changes to this project will be documented in this file.

- @josegonzalez Upgrade to circleci 2.1
- @josegonzalez Upgrade to golang 1.13.8

[unreleased]: https://github.com/gliderlabs/registrator/compare/v0.6.0...HEAD
[v0.6.0]: https://github.com/gliderlabs/registrator/compare/v0.6.0...v0.5.0
[v0.5.0]: https://github.com/gliderlabs/registrator/compare/v0.5.0...v0.4.0
13 changes: 13 additions & 0 deletions Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:1.17.2-buster

RUN apt-get update \
&& apt install apt-transport-https build-essential curl gnupg2 lintian rpm rsync rubygems-integration ruby-dev ruby -qy \
&& git clone https://github.com/bats-core/bats-core.git /tmp/bats-core \
&& cd /tmp/bats-core \
&& ./install.sh /usr/local \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

RUN gem install --no-ri --no-rdoc --quiet rake fpm package_cloud

WORKDIR /src
3 changes: 3 additions & 0 deletions Dockerfile.hub
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY ./build/linux/gliderlabs-sigil-amd64 /gliderlabs-sigil
ENTRYPOINT ["/gliderlabs-sigil"]
253 changes: 194 additions & 59 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,73 +1,208 @@
NAME=sigil
ARCH=$(shell uname -m)
ORG=gliderlabs
VERSION=0.6.0
define DESCRIPTION
NAME = gliderlabs-sigil
EMAIL = [email protected]
MAINTAINER = gliderlabs
MAINTAINER_NAME = Jose Diaz-Gonzalez
REPOSITORY = sigil
HARDWARE = $(shell uname -m)
SYSTEM_NAME = $(shell uname -s | tr '[:upper:]' '[:lower:]')
BASE_VERSION ?= 0.7.0
IMAGE_NAME ?= $(MAINTAINER)/$(REPOSITORY)
PACKAGECLOUD_REPOSITORY ?= dokku/dokku-betafish

ifeq ($(CI_BRANCH),release)
VERSION ?= $(BASE_VERSION)
DOCKER_IMAGE_VERSION = $(VERSION)
else
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

version:
@echo "$(CI_BRANCH)"
@echo "$(VERSION)"

define PACKAGE_DESCRIPTION
Standalone string interpolator and template processor
Sigil is a command line tool for template processing
and POSIX-compliant variable expansion. It was created
for configuration templating, but can be used for any
text processing.
endef
REPO_NAME ?= gliderlabs/sigil
ARCHITECTURE = amd64

export DESCRIPTION
export PACKAGE_DESCRIPTION

build:
glu build darwin,linux ./cmd
ifdef CIRCLECI
sudo chown -R circleci:circleci build
endif
$(MAKE) deb
$(MAKE) rpm
LIST = build release release-packagecloud validate
targets = $(addsuffix -in-docker, $(LIST))

test:
basht tests/*.bash
.env.docker:
@rm -f .env.docker
@touch .env.docker
@echo "CI_BRANCH=$(CI_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

install: build
install build/$(shell uname -s)/$(NAME) /usr/local/bin
build: prebuild
@$(MAKE) build/darwin/$(NAME)
@$(MAKE) build/linux/$(NAME)-amd64
@$(MAKE) build/linux/$(NAME)-armhf
@$(MAKE) build/deb/$(NAME)_$(VERSION)_amd64.deb
@$(MAKE) build/deb/$(NAME)_$(VERSION)_armhf.deb
@$(MAKE) build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm

deps:
go get github.com/gliderlabs/glu
go get -u github.com/progrium/basht/...
go get -d ./cmd
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 /usr/bin/docker:/usr/local/bin/docker \
--volume ${PWD}:/src/github.com/$(MAINTAINER)/$(REPOSITORY) \
--workdir /src/github.com/$(MAINTAINER)/$(REPOSITORY) \
$(IMAGE_NAME):build make -e $(@:-in-docker=)

build/darwin/$(NAME):
mkdir -p build/darwin
CGO_ENABLED=0 GOOS=darwin go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/darwin/$(NAME) cmd/sigil.go

build/linux/$(NAME)-amd64:
mkdir -p build/linux
CGO_ENABLED=0 GOOS=linux go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/linux/$(NAME)-amd64 cmd/sigil.go

build/linux/$(NAME)-armhf:
mkdir -p build/linux
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/linux/$(NAME)-armhf cmd/sigil.go

build/deb/$(NAME)_$(VERSION)_amd64.deb: build/linux/$(NAME)-amd64
export SOURCE_DATE_EPOCH=$(shell git log -1 --format=%ct) \
&& mkdir -p build/deb \
&& fpm \
--architecture amd64 \
--category utils \
--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)-amd64=/usr/bin/$(NAME) \
LICENSE=/usr/share/doc/$(NAME)/copyright

release:
glu release v$(VERSION)
package_cloud push "dokku/dokku/ubuntu/xenial" build/deb/$(subst /,_,$(REPO_NAME))_$(VERSION)_amd64.deb
package_cloud push "dokku/dokku/ubuntu/bionic" build/deb/$(subst /,_,$(REPO_NAME))_$(VERSION)_amd64.deb
package_cloud push "dokku/dokku/ubuntu/focal" build/deb/$(subst /,_,$(REPO_NAME))_$(VERSION)_amd64.deb
package_cloud push "dokku/dokku/debian/buster" build/deb/$(subst /,_,$(REPO_NAME))_$(VERSION)_amd64.deb
package_cloud push "dokku/dokku/debian/stretch" build/deb/$(subst /,_,$(REPO_NAME))_$(VERSION)_amd64.deb
package_cloud push "dokku/dokku/el/7" build/rpm/$(subst /,-,$(REPO_NAME))-$(VERSION)-1.x86_64.rpm
build/deb/$(NAME)_$(VERSION)_armhf.deb: build/linux/$(NAME)-armhf
export SOURCE_DATE_EPOCH=$(shell git log -1 --format=%ct) \
&& mkdir -p build/deb \
&& fpm \
--architecture armhf \
--category utils \
--description "$$PACKAGE_DESCRIPTION" \
--input-type dir \
--license 'MIT License' \
--maintainer "$(MAINTAINER_NAME) <$(EMAIL)>" \
--name $(NAME) \
--output-type deb \
--package build/deb/$(NAME)_$(VERSION)_armhf.deb \
--url "https://github.com/$(MAINTAINER)/$(REPOSITORY)" \
--vendor "" \
--version $(VERSION) \
--verbose \
build/linux/$(NAME)-armhf=/usr/bin/$(NAME) \
LICENSE=/usr/share/doc/$(NAME)/copyright

build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm: build/linux/$(NAME)-amd64
export SOURCE_DATE_EPOCH=$(shell git log -1 --format=%ct) \
&& mkdir -p build/rpm \
&& fpm \
--architecture x86_64 \
--category utils \
--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)-amd64=/usr/bin/$(NAME) \
LICENSE=/usr/share/doc/$(NAME)/copyright

clean:
rm -rf build release

.PHONY: build release

deb:
mkdir -p build/deb
fpm -t deb -s dir -n $(subst /,-,$(REPO_NAME)) \
--version $(VERSION) \
--architecture amd64 \
--package build/deb/$(subst /,_,$(REPO_NAME))_$(VERSION)_amd64.deb \
--url "https://github.com/$(REPO_NAME)" \
--maintainer "Jose Diaz-Gonzalez <[email protected]>" \
--category utils \
--description "$$DESCRIPTION" \
--license 'MIT License' \
build/Linux/sigil=/usr/bin/$(NAME)

rpm:
mkdir -p build/rpm
fpm -t rpm -s dir -n $(subst /,-,$(REPO_NAME)) \
--version $(VERSION) \
--architecture x86_64 \
--package build/rpm/$(subst /,-,$(REPO_NAME))-$(VERSION)-1.x86_64.rpm \
--url "https://github.com/$(REPO_NAME)" \
--category utils \
--description "$$DESCRIPTION" \
--license 'MIT License' \
build/Linux/sigil=/usr/bin/$(NAME)
rm -rf build release validation

ci-report:
docker version
rm -f ~/.gitconfig

docker-image:
docker build --rm -q -f Dockerfile.hub -t $(IMAGE_NAME):$(DOCKER_IMAGE_VERSION) .

bin/gh-release:
mkdir -p bin
curl -o bin/gh-release.tgz -sL https://github.com/progrium/gh-release/releases/download/v2.3.3/gh-release_2.3.3_$(SYSTEM_NAME)_$(HARDWARE).tgz
tar xf bin/gh-release.tgz -C bin
chmod +x bin/gh-release

release: build bin/gh-release
rm -rf release && mkdir release
tar -zcf release/$(NAME)_$(VERSION)_linux_amd64.tgz -C build/linux $(NAME)-amd64
tar -zcf release/$(NAME)_$(VERSION)_linux_armhf.tgz -C build/linux $(NAME)-armhf
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/deb/$(NAME)_$(VERSION)_armhf.deb release/$(NAME)_$(VERSION)_armhf.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 build/deb/$(NAME)_$(VERSION)_armhf.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/bionic build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/ubuntu/focal 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
package_cloud push $(PACKAGECLOUD_REPOSITORY)/debian/bullseye build/deb/$(NAME)_$(VERSION)_amd64.deb
package_cloud push $(PACKAGECLOUD_REPOSITORY)/raspbian/buster build/deb/$(NAME)_$(VERSION)_armhf.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:
mkdir -p validation
lintian build/deb/$(NAME)_$(VERSION)_amd64.deb || true
lintian build/deb/$(NAME)_$(VERSION)_armhf.deb || true
dpkg-deb --info build/deb/$(NAME)_$(VERSION)_amd64.deb
dpkg-deb --info build/deb/$(NAME)_$(VERSION)_armhf.deb
dpkg -c build/deb/$(NAME)_$(VERSION)_amd64.deb
dpkg -c build/deb/$(NAME)_$(VERSION)_armhf.deb
cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_amd64.deb
cd validation && ar -x ../build/deb/$(NAME)_$(VERSION)_armhf.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/deb/$(NAME)_$(VERSION)_armhf.deb
sha1sum build/rpm/$(NAME)-$(VERSION)-1.x86_64.rpm
go get -u github.com/progrium/basht/...
basht tests/*.bash

prebuild:
true
Loading

0 comments on commit 7a0409c

Please sign in to comment.