Giter VIP home page Giter VIP logo

hammer's Introduction

Hammer

Build Status

Hammer takes YAML specs and uses them to build packages (with FPM.) Here's a fairly complete sample annotated with comments.

---
# the following basic attributes can be used in templates uppercased - so "name"
# becomes "{{.Name}}", with one exception: "url" becomes "{{.URL}}"
name: consul
version: 0.5.2
license: MPLv2.0
iteration: 1
epoch: 1
vendor: Hashicorp
url: https://consul.io
architecture: x86_64
description: Consul is a tool for service discovery and configuration.

# list of targets that the built package will depend on
depends:
- systemd

# a list of resources (this can be source, but in this case is prebuilt
# binaries.) The URLs in this list can use template variables.
resources:
- url: https://dl.bintray.com/mitchellh/consul/{{.Version}}_linux_amd64.zip
    hash-type: sha1
    hash: b3ae610c670fc3b81737d44724ebde969da66ebf
- url: https://dl.bintray.com/mitchellh/consul/{{.Version}}_web_ui.zip
    hash-type: sha1
    hash: 67a2665e3c6aa6ca95c24d6176641010a1002cd6

# targets that will be copied into the package after the build is successful.
# The sources and destinations here can use template variables, and the content
# of the files can be templated as well, by providing `template: true` to any of
# the targets. Targets can also be marked as configuration files with the
# `config: true` option.
targets:
- src: "{{.BuildRoot}}/consul"
    dest: /usr/bin/
- src: "{{.BuildRoot}}/dist/"
    dest: /usr/share/consul-ui/
- src: "{{.SpecRoot}}/consul.service"
    dest: /etc/systemd/system/consul.service
- src: "{{.SpecRoot}}/consul.json"
    dest: /etc/consul/
    config: true
- src: "{{.SpecRoot}}/consul-ui.json"
    dest: /etc/consul/
    config: true
- src: "{{.SpecRoot}}/consul.sysconfig"
    dest: /etc/sysconfig/consul
    config: true

# scripts for building and installing the package. The only required script is
# "build", and "{before,after}-{install,remove,upgrade}" are available. You can
# also use template variables in the content of these scripts.
scripts:
build: |
    unzip {{.Version}}_linux_amd64.zip
    unzip {{.Version}}_web_ui.zip

before-install: |
    getent group consul > /dev/null || groupadd -r consul
    getent passwd consul > /dev/null || \
        useradd -r \
                -g consul \
                -d /var/lib/consul \
                -s /sbin/nologin \
                -c "consul.io user" \
                consul

    mkdir /var/lib/consul
    chown -R consul /var/lib/consul

after-install: |
    systemctl enable /etc/systemd/system/consul.service
    systemctl start consul.service

before-remove: |
    systemctl disable consul.service

after-remove: |
    rm -rf /var/lib/consul

after-upgrade: |
    systemctl reload-daemon
    systemctl restart consul.service

# extra options to FPM for building RPMs. Other package support (deb, for
# example) is not currently supported but not terribly hard to add. Open an
# issue if you want it.
rpm:
    os: linux
    dist: CentOS

When saved as spec.yml in some folder, Hammer will find and execute it, producing a package. Most fields are templated, and you can use Go templates to get fields on the Package struct.

Installation

First, you'll need to get FPM (which should just be gem install fpm) and any build tools you need (for example, to build RPMs you'll need rpmbuild.) Then, go install github.com/asteris-llc/hammer.

Contributing

Got a feature you'd like to see? PRs are very welcome. Just make sure that your build passes all the checks on gometalinter. Tests are appreciated, as well!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.