Skip to content

Commit

Permalink
Adding DEB and RPM package builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jtyr committed Nov 15, 2017
1 parent bb381b6 commit aaf531e
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 17 deletions.
57 changes: 41 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ matrix:

before_install:
- go get github.com/golang/lint/golint
- if [ -n "$TRAVIS_TAG" ]; then sudo apt-get install -y rpm; fi
- type dpkg-buildpackage
- if [ -n "$TRAVIS_TAG" ]; then sudo apt-get install -y rpm build-essential fakeroot; fi

before_script:
- golint ./...
Expand All @@ -22,22 +21,48 @@ before_script:
script:
- go install
- $GOPATH/bin/gbt -version

before_deploy:
- dist/build.sh
- if [ -n "$TRAVIS_TAG" ]; then dist/build.sh; fi

deploy:
provider: releases
api_key:
secure: T4S4Ea82+QpI0CNHYHZTKRe9L4lJ6TKEb2zsvAwvd8fdmR58L6N+0WhNQ6f6zczBl5ufeAvWlmYdLVCViFMzZVHOYkgT+ehSuT1wTh1sSpPpxATzN9nl53bsDxH1pSL0uht+os7HYXDZDsIr1Kpn6NbFeCJKdXhqb+0HgXyNc+k5jFMNSBkJsCY8aeegr9e6W7l6QvGwaAzqm4MNGgXeIw6uqMf5r0H4OqswudfaQ3/SOz1eTn1GvGNOCYmyM519Jd0hPvvLANzAqwC4M93yVdZm/fahZbY20HvELNbO2mXJUND4ojw/GcXRMjfx1c9TcvhFeBQNZPwHNGPc1ygoKo+BrRf7ZhY2WcwL580mT4yEbvtSbYUFqGNW1J+HiVr2BdYzOLK5jIEuaRrc1ex/BUUvyLGyd2b74NtHATYynG1Bjfu9LwDiVoo5zzpDfCPf00jIH8oC91zS41K7PrlC3kVchijU5wJDQ05dabThxb3RQ5lumrqZYEajG+hpm1+9DEQ3M1jJBSRY/frc8Gr3PTlfrc+INZXrp3vaFFjmISQYuEy1qFpoSTwnBK7eGzFL/B5jfPveJcjpHlINqGGQ3ilv2RLkSRh3ima0xHhtyDmUSF9cT26VrfPfOeytFtMwWHIFToiZtnqFd8VZk3DUyCDsTXWMtF+OMyhipd2MD4s=
file_glob: true
file:
- /tmp/gbt/*.tar.gz
- /tmp/gbt/*.txt
skip_cleanup: true
on:
tags: true
repo: jtyr/gbt
- provider: releases
api_key:
secure: T4S4Ea82+QpI0CNHYHZTKRe9L4lJ6TKEb2zsvAwvd8fdmR58L6N+0WhNQ6f6zczBl5ufeAvWlmYdLVCViFMzZVHOYkgT+ehSuT1wTh1sSpPpxATzN9nl53bsDxH1pSL0uht+os7HYXDZDsIr1Kpn6NbFeCJKdXhqb+0HgXyNc+k5jFMNSBkJsCY8aeegr9e6W7l6QvGwaAzqm4MNGgXeIw6uqMf5r0H4OqswudfaQ3/SOz1eTn1GvGNOCYmyM519Jd0hPvvLANzAqwC4M93yVdZm/fahZbY20HvELNbO2mXJUND4ojw/GcXRMjfx1c9TcvhFeBQNZPwHNGPc1ygoKo+BrRf7ZhY2WcwL580mT4yEbvtSbYUFqGNW1J+HiVr2BdYzOLK5jIEuaRrc1ex/BUUvyLGyd2b74NtHATYynG1Bjfu9LwDiVoo5zzpDfCPf00jIH8oC91zS41K7PrlC3kVchijU5wJDQ05dabThxb3RQ5lumrqZYEajG+hpm1+9DEQ3M1jJBSRY/frc8Gr3PTlfrc+INZXrp3vaFFjmISQYuEy1qFpoSTwnBK7eGzFL/B5jfPveJcjpHlINqGGQ3ilv2RLkSRh3ima0xHhtyDmUSF9cT26VrfPfOeytFtMwWHIFToiZtnqFd8VZk3DUyCDsTXWMtF+OMyhipd2MD4s=
file_glob: true
file:
- /tmp/gbt/*.tar.gz
- /tmp/gbt/*.deb
- /tmp/gbt/*.rpm
- /tmp/gbt/*.txt
skip_cleanup: true
on:
tags: true
repo: jtyr/gbt

- provider: packagecloud
repository: gbt
username: jtyr
token:
secure: 2pEkYy8r52+w2vaYT2rNq26fO2EUZfFe+ra7ZVCOyNzVRQ0EgIm0bsL6AidhQM4ab5rT1RyEvVyLDkYp3HhtD/GckklVehjWZvvkUscYRZPkaaEHZ0OzifusPdD6IQYB8wjN6rPnpC4FTPRgk+Uu3KOGXUAJwjsPOoYrZOM3yM+kxgmE5pDNUw6SpCrft4XcCQ0pIXdYuYdkG9rzWiTST4FFmDYbCkFz4516+0MNwBfL6LnwQ7ynL8tXaRo99J6fvTxlsiBt2T51yzaMUM6m2KGB67y49iMxGJ76ZH/roLFPSlzvRADgB5UCEhIOevp1HkhEUb4njxS/hZr0lv01FOo2XBoor7U08r/uZv0LFk3Da3ldzyXYscBUirmVvLRE8jxSrZ7r9gtPj0wUOSdDJSqSHhq3dhhcOisbmxepo3cRlxEo+9B05i1kfyjHLckyEvd5cp5FTvAPNIN16mwrdc8YwXdUarhbZPzhOT75cNt+Fj4P9h8zyhi/0GE49UL3Ns38BEXfUYdqwwlzvhskqYssEdH1ettwZ+0X0EY84a/5tpn61MsHIJg9D9QYffYaQcI+kSB/Qfeo7vkhKG3oW/OpoB8uNTrIu/eRZqZ/JoTrarZ+iXTKfK57X2RybRv4QE3XOv6O0B9ie3/1qZU31UewgZ83knU6v5xgsaexv98=
dist: ubuntu/xenial
skip_cleanup: true
local-dir: /tmp/gbt
package_glob: "*.deb"
on:
tags: true
repo: jtyr/gbt

- provider: packagecloud
repository: gbt
username: jtyr
token:
secure: 2pEkYy8r52+w2vaYT2rNq26fO2EUZfFe+ra7ZVCOyNzVRQ0EgIm0bsL6AidhQM4ab5rT1RyEvVyLDkYp3HhtD/GckklVehjWZvvkUscYRZPkaaEHZ0OzifusPdD6IQYB8wjN6rPnpC4FTPRgk+Uu3KOGXUAJwjsPOoYrZOM3yM+kxgmE5pDNUw6SpCrft4XcCQ0pIXdYuYdkG9rzWiTST4FFmDYbCkFz4516+0MNwBfL6LnwQ7ynL8tXaRo99J6fvTxlsiBt2T51yzaMUM6m2KGB67y49iMxGJ76ZH/roLFPSlzvRADgB5UCEhIOevp1HkhEUb4njxS/hZr0lv01FOo2XBoor7U08r/uZv0LFk3Da3ldzyXYscBUirmVvLRE8jxSrZ7r9gtPj0wUOSdDJSqSHhq3dhhcOisbmxepo3cRlxEo+9B05i1kfyjHLckyEvd5cp5FTvAPNIN16mwrdc8YwXdUarhbZPzhOT75cNt+Fj4P9h8zyhi/0GE49UL3Ns38BEXfUYdqwwlzvhskqYssEdH1ettwZ+0X0EY84a/5tpn61MsHIJg9D9QYffYaQcI+kSB/Qfeo7vkhKG3oW/OpoB8uNTrIu/eRZqZ/JoTrarZ+iXTKfK57X2RybRv4QE3XOv6O0B9ie3/1qZU31UewgZ83knU6v5xgsaexv98=
dist: el/7
skip_cleanup: true
local-dir: /tmp/gbt
package_glob: "*.rpm"
on:
tags: true
repo: jtyr/gbt

notifications:
email: false
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,35 @@ PROMPT='$(gbt $?)'
PS1='$(gbt $?)'
```

or on CentOS/RHEL:

```shell
cat > /etc/yum.repos.d/gbt.repo <<END
[gbt]
name=GBT YUM repo
baseurl=https://packagecloud.io/jtyr/gbt/el/7/\$basearch
gpgcheck=0
END
yum install gbt
# For ZSH
PROMPT='$(gbt $?)'
# For Bash
PS1='$(gbt $?)'
```

or on Ubuntu/Debian:

```shell
curl -L https://packagecloud.io/jtyr/gbt/gpgkey | apt-key add -
echo 'deb https://packagecloud.io/jtyr/gbt/ubuntu/ xenial main' > /etc/apt/sources.list.d/gbt.list
apt-get update
apt-get install gbt
# For ZSH
PROMPT='$(gbt $?)'
# For Bash
PS1='$(gbt $?)'
```

or on Mac via [`brew`](https://brew.sh/):

```shell
Expand Down
5 changes: 5 additions & 0 deletions contrib/debian/changelog.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gbt (VER) stable; urgency=low

* Version bump to VER.

-- Jiri Tyr <[email protected]> DATE
10 changes: 10 additions & 0 deletions contrib/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Source: gbt
Section: utils
Priority: extra
Maintainer: Jiri Tyr <[email protected]>
Standards-Version: 4.1.1
Homepage: https://github.com/jtyr/gbt

Package: gbt
Architecture: any
Description: Highly configurable prompt builder for Bash and ZSH written in Go.
41 changes: 41 additions & 0 deletions contrib/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/make -f

define checkdir
@test -f debian/rules || \
(echo Not in correct source directory; exit 1)
endef

define checkroot
@test $$(id -u) = 0 || (echo need root priviledges; exit 1)
endef

PACKAGE = gbt
TOP_DIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
SRC_DIR = $(TOP_DIR)/$(PACKAGE)
DEST_DIR = $(TOP_DIR)/debian/$(PACKAGE)
BIN_DIR = $(DEST_DIR)/usr/bin
DOCS_DIR = $(DEST_DIR)/usr/share/doc/$(PACKAGE)
SHARE_DIR = $(DEST_DIR)/usr/share/$(PACKAGE)

build:

binary:
$(checkdir)
$(checkroot)
mkdir -p $(DEST_DIR)/DEBIAN $(BIN_DIR) $(DOCS_DIR) $(SHARE_DIR)
install -Dm755 $(SRC_DIR)/$(PACKAGE) -t $(BIN_DIR)
install -Dm644 $(SRC_DIR)/LICENSE -t $(DOCS_DIR)
install -Dm644 $(SRC_DIR)/README.md -t $(DOCS_DIR)
cp -r $(SRC_DIR)/sources $(SHARE_DIR)
cp -r $(SRC_DIR)/themes $(SHARE_DIR)
dpkg-gencontrol -P$(DEST_DIR)
cd $(DEST_DIR) && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums
dpkg-deb -b $(DEST_DIR) ../

clean:
$(checkdir)
-rm -rf debian/$(PACKAGE)
-rm -f debian/files
-rm -f debian/substvars

.PHONY: binary clean
37 changes: 37 additions & 0 deletions contrib/redhat/gbt.spec.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Name: gbt
Summary: Highly configurable prompt builder for Bash and ZSH written in Go.
Version: VER
Release: 1%{?dist}
License: MIT
URL: https://github.com/jtyr/gbt
Source: https://github.com/jtyr/%{name}/releases/download/v%{version}/%{name}-%{version}-linux-amd64.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: x86_64

%description
Highly configurable prompt builder for Bash and ZSH written in Go.

%prep
%setup -q

%install
[ "%{buildroot}" != / ] && %{__rm} -rf $RPM_BUILD_ROOT
%{__mkdir_p} %{buildroot}%{_bindir}
%{__mkdir_p} %{buildroot}%{_sharedstatedir}/%{name}
%{__cp} %{name} %{buildroot}%{_bindir}/%{name}
%{__cp} -r sources %{buildroot}%{_sharedstatedir}/%{name}
%{__cp} -r themes %{buildroot}%{_sharedstatedir}/%{name}

%clean
[ "%{buildroot}" != '/' ] && %{__rm} -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
%doc README.md
%doc LICENSE
%{_sharedstatedir}/%{name}/*
%{_bindir}/%{name}

%changelog
* Mon Nov 14 2017 Jiri Tyr <[email protected]> 1.1.0-1
- Initial build.
25 changes: 24 additions & 1 deletion dist/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,29 @@ for P in "${PLATFORMS[@]}"; do
cp -r "$TRAVIS_BUILD_DIR"/{README.md,LICENSE,themes,sources} "$PTMP"
tar -C "$PTMP/.." -czf "$TMP/$PKG" ./
cd "$TMP"
sha256sum "$PKG" >> "$TMP/$NAME-$VER-checksums.txt"
)

if [ "$OS" = 'linux' ]; then
# DEB
(
cd "$TRAVIS_BUILD_DIR/contrib"
ln -s "$PTMP" "$TRAVIS_BUILD_DIR/contrib/$NAME"
m4 -DVER="$VER" -DDATE="$(date '+%a, %d %b %Y %H:%M:%S %z')" debian/changelog.m4 > debian/changelog
dpkg-buildpackage -us -uc -tc -b
)
mv "$TRAVIS_BUILD_DIR"/*.deb $TMP

# RPM
mkdir -p ~/rpmbuild/SOURCES
ln -s "$TMP/$PKG" ~/rpmbuild/SOURCES/
(
cd "$TRAVIS_BUILD_DIR/contrib/redhat"
m4 -DVER="$VER" gbt.spec.m4 > gbt.spec
rpmbuild -bb gbt.spec
)
mv ~/rpmbuild/RPMS/x86_64/*.rpm "$TMP"
fi
done

cd "$TMP"
sha256sum *.tar.gz *.deb *.rpm > "$NAME-$VER-checksums.txt"

0 comments on commit aaf531e

Please sign in to comment.