Skip to content

Commit

Permalink
Remove makefile and replace with go generate
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Nov 24, 2019
1 parent a7a9bcb commit 9281a1c
Show file tree
Hide file tree
Showing 9 changed files with 333 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
tldr
9 changes: 1 addition & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ builds:
- linux
- darwin
- windows
- solaris
goarch:
- amd64
- 386

archive:
wrap_in_directory: true
Expand All @@ -24,12 +22,7 @@ archive:
- LICENSE-tldr-pages

brew:
github:
owner: leighmcculloch
name: homebrew-tldr
commit_author:
name: Leigh McCulloch
email: leigh@mcchouse.com
skip_upload: true
folder: Formula
homepage: "https://4d63.com/tldr"
description: Simplified and community-driven man pages (tldr-pages).
Expand Down
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

48 changes: 7 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,44 +1,10 @@
.PHONY: generate data setup

install: setup data generate
go get ./...
go install

release: setup-release
@: $(if ${GITHUB_TOKEN},,$(error GITHUB_TOKEN must be defined))
git tag -a $(VERSION) -m "$(VERSION)"
git push origin $(VERSION)
goreleaser --rm-dist --parallelism 1 || (git tag -d $(VERSION) && git push --delete origin $(VERSION))

autorelease: install
@: $(if ${GITHUB_TOKEN},,$(error GITHUB_TOKEN must be defined))
git add . && git diff --cached --exit-code || \
( \
echo 'New data files found, updating...' \
&& git commit -m "Update data files" \
&& git push origin master \
&& GITHUB_TOKEN="${GITHUB_TOKEN}" $(MAKE) release VERSION=v1.0.$$(date +%s)\
)

data:
rm -fr data
mkdir data
curl -sSL https://github.com/tldr-pages/tldr/raw/master/LICENSE.md -o LICENSE-tldr-pages
curl -sSL https://github.com/tldr-pages/tldr/archive/master.tar.gz | \
tar --transform 's/\.md//' -xz --directory data tldr-master/pages/ --strip-components=2
cp -n data/common/* data/linux/
cp -n data/common/* data/osx/
cp -n data/common/* data/sunos/
cp -n data/common/* data/windows/

generate:
cd data/linux && embedfiles -out ../../data_linux.go .
cd data/osx && embedfiles -out ../../data_darwin.go .
cd data/sunos && embedfiles -out ../../data_solaris.go .
cd data/windows && embedfiles -out ../../data_windows.go .
go generate

setup:
go get 4d63.com/embedfiles
build: generate
go build

setup-release:
go get github.com/goreleaser/goreleaser
release: generate
git diff --cached --exit-code
git add . && git diff --cached --exit-code
go run github.com/goreleaser/goreleaser --rm-dist
3 changes: 3 additions & 0 deletions data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package main

//go:generate sh data.sh
16 changes: 16 additions & 0 deletions data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#! /usr/bin/env sh

cwd="$PWD"

rm -fr data
mkdir data
curl -sSL https://github.com/tldr-pages/tldr/raw/master/LICENSE.md -o LICENSE-tldr-pages
curl -sSL https://github.com/tldr-pages/tldr/archive/master.tar.gz | tar --transform 's/\.md//' -xz --directory data tldr-master/pages/ --strip-components=2
cp -n data/common/* data/linux/
cp -n data/common/* data/osx/
cp -n data/common/* data/sunos/
cp -n data/common/* data/windows/
cd "$cwd"/data/linux && go run 4d63.com/embedfiles -out ../../data_linux.go .
cd "$cwd"/data/osx && go run 4d63.com/embedfiles -out ../../data_darwin.go .
cd "$cwd"/data/sunos && go run 4d63.com/embedfiles -out ../../data_solaris.go .
cd "$cwd"/data/windows && go run 4d63.com/embedfiles -out ../../data_windows.go .
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ module 4d63.com/tldr
go 1.13

require (
4d63.com/embedfiles v1.0.0
github.com/fatih/color v1.7.0
github.com/goreleaser/goreleaser v0.123.2
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
)
295 changes: 295 additions & 0 deletions go.sum

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// +build tools

package main

import (
_ "4d63.com/embedfiles"
_ "github.com/goreleaser/goreleaser"
)

0 comments on commit 9281a1c

Please sign in to comment.