mirror of
https://github.com/jaspervdj/patat.git
synced 2024-11-26 09:52:59 +03:00
Add builds for Mac OS
This commit is contained in:
parent
a81e647c91
commit
19c7ecb921
@ -4,13 +4,40 @@ workflows:
|
||||
version: 2
|
||||
build-workflow:
|
||||
jobs:
|
||||
- build:
|
||||
- build-macos:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
- build-linux:
|
||||
filters:
|
||||
tags:
|
||||
only: /.*/
|
||||
|
||||
jobs:
|
||||
build:
|
||||
build-macos:
|
||||
macos:
|
||||
xcode: '10.0.0'
|
||||
steps:
|
||||
- run:
|
||||
name: 'Set up PATH'
|
||||
command: echo "export PATH=$HOME/.local/bin:$PATH" >> $BASH_ENV
|
||||
- checkout
|
||||
- run:
|
||||
name: 'Install stack'
|
||||
command: 'curl -sSL https://get.haskellstack.org/ | sh'
|
||||
- restore_cache:
|
||||
key: 'v6-{{ arch }}'
|
||||
- run:
|
||||
command: 'make build test'
|
||||
- save_cache:
|
||||
key: 'v6-{{ arch }}'
|
||||
paths:
|
||||
- '~/.stack'
|
||||
- run:
|
||||
name: 'Upload release'
|
||||
command: 'if [[ ! -z "$CIRCLE_TAG" ]]; then make release; fi'
|
||||
|
||||
build-linux:
|
||||
# This image has most Haskell stuff preinstalled.
|
||||
docker:
|
||||
- image: 'haskell:8.6'
|
||||
@ -18,20 +45,13 @@ jobs:
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
key: 'v5-patat-{{ arch }}-{{ .Branch }}'
|
||||
key: 'v6-{{ arch }}'
|
||||
- run:
|
||||
# We set jobs to 1 here because that prevents Out-Of-Memory exceptions
|
||||
# while compiling dependencies.
|
||||
name: 'Install'
|
||||
command: '.circleci/tickle.sh stack build --pedantic --copy-bins --jobs=1 --no-terminal --test'
|
||||
- run:
|
||||
name: 'Run golden tests'
|
||||
command: 'make test'
|
||||
command: 'make build test'
|
||||
- save_cache:
|
||||
key: 'v5-patat-{{ arch }}-{{ .Branch }}-{{ .Revision }}'
|
||||
key: 'v6-{{ arch }}'
|
||||
paths:
|
||||
- '~/.stack-work'
|
||||
- '~/.stack'
|
||||
- run:
|
||||
name: 'Upload release'
|
||||
command: '.circleci/release.sh "$CIRCLE_TAG"'
|
||||
command: 'if [[ ! -z "$CIRCLE_TAG" ]]; then make release; fi'
|
||||
|
@ -1,47 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o nounset -o errexit -o pipefail
|
||||
|
||||
TAG="$1"
|
||||
SUFFIX="linux-$(uname -m)"
|
||||
USER="jaspervdj"
|
||||
REPOSITORY="$(basename -- *.cabal ".cabal")"
|
||||
BINARY="$REPOSITORY"
|
||||
|
||||
echo "Tag: $TAG"
|
||||
echo "Suffix: $SUFFIX"
|
||||
echo "Repository: $REPOSITORY"
|
||||
|
||||
$BINARY --version
|
||||
|
||||
if [[ -z "$TAG" ]]; then
|
||||
echo "Not a tagged build, skipping release..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Install ghr
|
||||
GHR_VERSION="v0.13.0"
|
||||
curl --silent -L -O \
|
||||
"https://github.com/tcnksm/ghr/releases/download/${GHR_VERSION}/ghr_${GHR_VERSION}_linux_386.tar.gz"
|
||||
tar xf ghr_${GHR_VERSION}_linux_386.tar.gz
|
||||
mv ghr_${GHR_VERSION}_linux_386/ghr .
|
||||
|
||||
# Install upx
|
||||
UPX_VERSION="3.94"
|
||||
curl --silent -L -O \
|
||||
"https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-amd64_linux.tar.xz"
|
||||
tar xf upx-${UPX_VERSION}-amd64_linux.tar.xz
|
||||
mv upx-${UPX_VERSION}-amd64_linux/upx .
|
||||
|
||||
# Create tarball
|
||||
PACKAGE="$REPOSITORY-$TAG-$SUFFIX"
|
||||
mkdir -p "$PACKAGE"
|
||||
cp "$(which "$BINARY")" "$PACKAGE"
|
||||
./upx -q "$PACKAGE/$BINARY"
|
||||
cp README.* "$PACKAGE"
|
||||
cp CHANGELOG.* "$PACKAGE"
|
||||
cp extra/patat.1 "$PACKAGE"
|
||||
tar -czf "$PACKAGE.tar.gz" "$PACKAGE"
|
||||
rm -r "$PACKAGE"
|
||||
|
||||
# Actually upload
|
||||
./ghr -u "$USER" -r "$REPOSITORY" "$TAG" "$PACKAGE.tar.gz"
|
@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -o nounset -o errexit -o pipefail
|
||||
|
||||
function tickle() {
|
||||
while [ true ]; do
|
||||
echo "[$(date +%H:%M:%S)] Tickling..."
|
||||
sleep 60
|
||||
done
|
||||
}
|
||||
|
||||
echo "Forking tickle process..."
|
||||
tickle &
|
||||
TICKLE_PID=$!
|
||||
|
||||
echo "Forking build process..."
|
||||
eval $@ &
|
||||
BUILD_PID=$!
|
||||
|
||||
echo "Waiting for build thread ($BUILD_PID)..."
|
||||
wait $BUILD_PID
|
||||
|
||||
echo "Killing tickle thread ($TICKLE_PID)..."
|
||||
kill $TICKLE_PID
|
||||
echo "All done!"
|
86
Makefile
86
Makefile
@ -1,26 +1,104 @@
|
||||
ARCH=$(shell uname -m)
|
||||
UNAME=$(shell uname | tr 'A-Z' 'a-z')
|
||||
|
||||
PATAT_BINARY=$(HOME)/.local/bin/patat
|
||||
PATAT_VERSION=$(shell sed -n 's/^Version: *//p' *.cabal)
|
||||
PATAT_PACKAGE=patat-v$(PATAT_VERSION)-$(UNAME)-$(ARCH)
|
||||
|
||||
GHR_VERSION=0.13.0
|
||||
GHR_NAME=ghr_v$(GHR_VERSION)_$(UNAME)_amd64
|
||||
GHR_BINARY=$(HOME)/.local/bin/ghr
|
||||
|
||||
UPX_VERSION=3.94
|
||||
UPX_NAME=upx-$(UPX_VERSION)-amd64_$(UNAME)
|
||||
UPX_BINARY=$(HOME)/.local/bin/upx
|
||||
|
||||
ifeq ($(UNAME), darwin)
|
||||
ARCHIVE=zip
|
||||
ARCHIVE_CREATE=zip -r
|
||||
ARCHIVE_EXTRACT=unzip
|
||||
else
|
||||
ARCHIVE=tar.gz
|
||||
ARCHIVE_CREATE=tar czf
|
||||
ARCHIVE_EXTRACT=tar xvzf
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME), darwin)
|
||||
# We use `?=` to set SOURCE_DATE_EPOCH only if it is not present. Unfortunately
|
||||
# we can't use `git --date=unix` since only very recent git versions support
|
||||
# that, so we need to make a round trip through `date`.
|
||||
SOURCE_DATE_EPOCH?=$(shell git log -1 --format=%cd --date=unix)
|
||||
else
|
||||
SOURCE_DATE_EPOCH?=$(shell date '+%s' \
|
||||
--date="$(shell git log -1 --format=%cd --date=rfc)")
|
||||
--date="$(shell git log -1 --format=%cd --date=rfc)")
|
||||
endif
|
||||
|
||||
extra/patat.1: README.md
|
||||
ifeq ($(UNAME), darwin)
|
||||
COMPRESS_BIN_DEPS=
|
||||
COMPRESS_BIN=ls
|
||||
else
|
||||
COMPRESS_BIN_DEPS=$(UPX_BINARY)
|
||||
COMPRESS_BIN=upx
|
||||
endif
|
||||
|
||||
# Default target.
|
||||
build: $(PATAT_BINARY)
|
||||
|
||||
# Upload a release.
|
||||
release: $(PATAT_PACKAGE).$(ARCHIVE) $(GHR_BINARY)
|
||||
ghr -u jaspervdj -r patat v$(PATAT_VERSION) $(PATAT_PACKAGE).$(ARCHIVE)
|
||||
|
||||
$(PATAT_PACKAGE).$(ARCHIVE): $(PATAT_BINARY) extra/patat.1 $(COMPRESS_BIN_DEPS)
|
||||
mkdir $(PATAT_PACKAGE)
|
||||
cp $(PATAT_BINARY) $(PATAT_PACKAGE)/
|
||||
$(COMPRESS_BIN) $(PATAT_PACKAGE)/patat
|
||||
cp README.md $(PATAT_PACKAGE)/
|
||||
cp CHANGELOG.md $(PATAT_PACKAGE)/
|
||||
cp LICENSE $(PATAT_PACKAGE)/
|
||||
cp extra/patat.1 $(PATAT_PACKAGE)/
|
||||
$(ARCHIVE_CREATE) $(PATAT_PACKAGE).$(ARCHIVE) $(PATAT_PACKAGE)
|
||||
|
||||
$(PATAT_BINARY):
|
||||
stack build -j1 --copy-bins --pedantic
|
||||
|
||||
# GHR is used to upload releases to GitHub.
|
||||
$(GHR_BINARY):
|
||||
curl -Lo /tmp/$(GHR_NAME).$(ARCHIVE) \
|
||||
https://github.com/tcnksm/ghr/releases/download/v$(GHR_VERSION)/$(GHR_NAME).$(ARCHIVE)
|
||||
cd /tmp && $(ARCHIVE_EXTRACT) $(GHR_NAME).$(ARCHIVE)
|
||||
mv /tmp/$(GHR_NAME)/ghr $(GHR_BINARY)
|
||||
ghr --version
|
||||
|
||||
# UPX is used to compress the resulting binary. We currently don't use this on
|
||||
# Mac OS.
|
||||
$(UPX_BINARY):
|
||||
curl -Lo /tmp/$(UPX_NAME).tar.xz \
|
||||
https://github.com/upx/upx/releases/download/v$(UPX_VERSION)/$(UPX_NAME).tar.xz
|
||||
cd /tmp && tar xf $(UPX_NAME).tar.xz
|
||||
mv /tmp/$(UPX_NAME)/upx $(UPX_BINARY)
|
||||
upx --version
|
||||
|
||||
# Man page.
|
||||
extra/patat.1: README.md $(PATAT_BINARY)
|
||||
SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" patat-make-man >$@
|
||||
|
||||
# Bash completion.
|
||||
extra/patat.bash-completion:
|
||||
patat --bash-completion-script patat >$@
|
||||
|
||||
.PHONY: completion
|
||||
completion: extra/patat.bash-completion
|
||||
|
||||
.PHONY: man
|
||||
man: extra/patat.1
|
||||
|
||||
# Also check if we can generate the manual.
|
||||
.PHONY: test
|
||||
test: man
|
||||
bash tests/golden.sh
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f extra/patat.1
|
||||
rm -f extra/make-man
|
||||
rm -f extra/patat.bash-completion
|
||||
|
||||
.PHONY: man completion test clean
|
||||
|
@ -62,7 +62,7 @@ Installation
|
||||
- openSUSE: <https://build.opensuse.org/package/show/openSUSE:Factory:ARM/patat>
|
||||
- Fedora: <https://src.fedoraproject.org/rpms/patat>
|
||||
|
||||
You can also find generic linux binaries here:
|
||||
You can also find generic Linux and Mac OS binaries here:
|
||||
<https://github.com/jaspervdj/patat/releases>.
|
||||
|
||||
### From source
|
||||
|
Loading…
Reference in New Issue
Block a user