forked from Siderus/Orion
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
147 lines (127 loc) · 4.66 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# we need the go-ipfs binary
IPFS_VERSION := $(shell node -p "require('./package.json').ipfsVersion")
IPFS_BINARY_NAME ?= go-ipfs_${IPFS_VERSION}_${TARGET}-amd64${BINARY_EXT}
BINARY_URL ?= https://dist.ipfs.io/go-ipfs/${IPFS_VERSION}/${IPFS_BINARY_NAME}
# we need the fs-repo-migrations binary
REPO_MIGRATIONS_VERSION := $(shell node -p "require('./package.json').ipfsRepoMigrationsVersion")
REPO_MIGRATIONS_BINARY_NAME ?= fs-repo-migrations_${REPO_MIGRATIONS_VERSION}_${TARGET}-amd64${BINARY_EXT}
REPO_MIGRATIONS_BINARY_URL ?= https://dist.ipfs.io/fs-repo-migrations/${REPO_MIGRATIONS_VERSION}/${REPO_MIGRATIONS_BINARY_NAME}
NODE_ENV ?= development
TMP_DIR := $(shell mktemp -d)
GH_TOKEN ?=
SNAPCRAFT_TOKEN ?=
ifeq ($(OS),Windows_NT)
BINARY_EXT := .zip
DECOMPRESSOR := unzip
TARGET := windows
BUILD_ARGS += --windows
else
BINARY_EXT := .tar.gz
DECOMPRESSOR := tar xf
UNAME_S ?= $(shell uname -s)
ifeq ($(UNAME_S),Linux)
TARGET := linux
BUILD_ARGS += --linux
endif
ifeq ($(UNAME_S),Darwin)
TARGET := darwin
BUILD_ARGS += --mac --x64
endif
endif
_test_variables:
@test -n "$(TARGET)" || (echo "Variable TARGET not set"; exit 1)
@test -n "$(NODE_ENV)" || (echo "Variable TARGET not set"; exit 1)
@test -n "$(IPFS_VERSION)" || (echo "Variable IPFS_VERSION not set"; exit 1)
@test -n "$(BINARY_URL)" || (echo "Variable BINARY_URL not set"; exit 1)
@test -n "$(REPO_MIGRATIONS_VERSION)" || (echo "Variable REPO_MIGRATIONS_VERSION not set"; exit 1)
@test -n "$(REPO_MIGRATIONS_BINARY_URL)" || (echo "Variable REPO_MIGRATIONS_BINARY_URL not set"; exit 1)
@test -n "$(DECOMPRESSOR)" || (echo "Variable DECOMPRESSOR not set"; exit 1)
@test -n "$(BUILD_ARGS)" || (echo "Variable BUILD_ARGS not set"; exit 1)
.PHONY: _test_variables
clean:
rm -rf .cache
rm -rf build
rm -rf go-ipfs
rm -rf coverage
rm -rf node_modules
rm -rf repo
rm -rf fs-repo-migrations
.PHONY: clean
# Yarn packages, tests and linting
dep:
yarn --link-duplicates --pure-lockfile
.PHONY: dep
run: dep
test -s go-ipfs/ipfs || "$(MAKE)" prepare_ipfs_bin
test -s fs-repo-migrations/fs-repo-migrations || "$(MAKE)" prepare_repo_migrations_bin
rm -rf .cache
yarn start
.PHONY: run
lint: dep
yarn lint
.PHONY: lint
test: dep
yarn test
.PHONY: test
# Building the packages for multiple platforms
build_icons: dep
./node_modules/.bin/icon-gen -i ./docs/logo.svg -o ./docs/ -m ico,icns -n ico=logo,icns=logo
.PHONY: build_icons
# uses electron-compile to build the app and ensures icons are there
_prepkg: dep _test_variables
mkdir -p build
cp ./docs/logo.icns ./build/
cp ./docs/logo.ico ./build/
NODE_ENV=${NODE_ENV} ./node_modules/.bin/electron-compile app
.PHONY: _prepkg
# This endpoints updatse package.json in order to make them realease ready!
prepare_release:
cat package.json | sed "s/-master\",$$/\",/g" >> package.new.json
mv package.new.json package.json
cat package.json | sed "s/\"development\",$$/\"release\",/g" >> package.new.json
mv package.new.json package.json
cat package.json | sed "s/\"9d407c14d888a212cf04c397a95acb7b\",$$/\"bcd802fa2e699f85cc19e1ff6079e3c7\",/g" >> package.new.json
mv package.new.json package.json
.PHONY: prepare_release_values
prepare_binaries: prepare_ipfs_bin prepare_repo_migrations_bin
.PHONY: prepare_binaries
# Download the go-ipfs binary from the URL
prepare_ipfs_bin: _test_variables
curl -o ./${IPFS_BINARY_NAME} ${BINARY_URL}
rm -rf ./go-ipfs
$(DECOMPRESSOR) ${IPFS_BINARY_NAME}
rm ${IPFS_BINARY_NAME}
.PHONY: prepare_ipfs_bin
# Download the fs-repo-migrations binary from the URL
prepare_repo_migrations_bin: _test_variables
curl -o ./${REPO_MIGRATIONS_BINARY_NAME} ${REPO_MIGRATIONS_BINARY_URL}
rm -rf ./fs-repo-migrations
$(DECOMPRESSOR) ${REPO_MIGRATIONS_BINARY_NAME}
rm ${REPO_MIGRATIONS_BINARY_NAME}
.PHONY: prepare_repo_migrations_bin
build_unpacked: _test_variables prepare_binaries _prepkg
./node_modules/.bin/build ${BUILD_ARGS} --dir
.PHONY: build_unpacked
build: _test_variables prepare_binaries _prepkg
./node_modules/.bin/build ${BUILD_ARGS}
.PHONY: build
build_all: clean
$(MAKE) build -e OS="Darwin" -e UNAME_S="Darwin"
$(MAKE) build -e OS="Linux" -e UNAME_S="Linux"
$(MAKE) build -e OS="Windows_NT"
.PHONY: build_all
release: _test_variables prepare_release prepare_binaries _prepkg
./node_modules/.bin/build ${BUILD_ARGS} --publish always
.PHONY: release
release_all: clean
$(MAKE) release -e OS="Darwin" -e UNAME_S="Darwin"
$(MAKE) release -e OS="Linux" -e UNAME_S="Linux"
$(MAKE) release -e OS="Windows_NT"
.PHONY: release_all
# Snapcraft publishing
snap_publish:
@echo "$${SNAPCRAFT_TOKEN}" >> ${TMP_DIR}/snap.txt
snapcraft login --with ${TMP_DIR}/snap.txt
snapcraft push --release=stable ./build/Orion_*.snap
rm ${TMP_DIR}/snap.txt
.PHONEY: snap_publish