120 lines
3.3 KiB
Makefile
120 lines
3.3 KiB
Makefile
LINT_ARGS ?= --timeout 5m
|
|
GITCHLOG_ARGS ?=
|
|
SHELL := /bin/bash
|
|
|
|
GOTEST_ARGS ?= -short -timeout 60s
|
|
|
|
ESBUILD_VERSION ?= v0.17.5
|
|
|
|
GIT_VERSION := $(shell git describe --always)
|
|
DATE_VERSION := $(shell date +%Y.%-m.%-d)
|
|
FULL_VERSION := v$(DATE_VERSION)-$(GIT_VERSION)$(if $(shell git diff --stat),-dirty,)
|
|
APP_PATH ?= misc/client-sdk-testsuite/dist
|
|
RUN_APP_ARGS ?=
|
|
RUN_STORAGE_SERVER_ARGS ?=
|
|
|
|
SHELL := bash
|
|
|
|
|
|
build: build-cli build-storage-server build-client-sdk-test-app
|
|
|
|
watch: tools/modd/bin/modd
|
|
tools/modd/bin/modd
|
|
|
|
.PHONY: test
|
|
test: test-go
|
|
|
|
test-go:
|
|
go test -count=1 $(GOTEST_ARGS) ./...
|
|
|
|
lint:
|
|
golangci-lint run --enable-all $(LINT_ARGS)
|
|
|
|
build-cli: build-sdk
|
|
CGO_ENABLED=0 go build \
|
|
-v \
|
|
-o ./bin/cli \
|
|
./cmd/cli
|
|
|
|
build-storage-server: build-sdk
|
|
CGO_ENABLED=0 go build \
|
|
-v \
|
|
-o ./bin/storage-server \
|
|
./cmd/storage-server
|
|
|
|
build-client-sdk-test-app:
|
|
cd misc/client-sdk-testsuite && $(MAKE) dist
|
|
|
|
install-git-hooks:
|
|
git config core.hooksPath .githooks
|
|
|
|
tools/esbuild/bin/esbuild:
|
|
mkdir -p tools/esbuild/bin
|
|
curl -fsSL https://esbuild.github.io/dl/$(ESBUILD_VERSION) | sh
|
|
mv -f esbuild tools/esbuild/bin/esbuild
|
|
|
|
build-sdk: pkg/sdk/client/dist/client.js
|
|
|
|
.PHONY: pkg/sdk/client/dist/client.js
|
|
pkg/sdk/client/dist/client.js: tools/esbuild/bin/esbuild node_modules
|
|
mkdir -p pkg/sdk/client/dist
|
|
tools/esbuild/bin/esbuild \
|
|
pkg/sdk/client/src/index.ts \
|
|
--minify \
|
|
--bundle \
|
|
--sourcemap \
|
|
--target=es2015 \
|
|
--format=iife \
|
|
--global-name=Edge \
|
|
--define:global=window \
|
|
--platform=browser \
|
|
--loader:.svg=dataurl \
|
|
--outfile=pkg/sdk/client/dist/client.js
|
|
|
|
node_modules:
|
|
npm ci
|
|
|
|
run-app: .env
|
|
( set -o allexport && source .env && set +o allexport && bin/cli app run -p $(APP_PATH) $$RUN_APP_ARGS )
|
|
|
|
run-storage-server: .env
|
|
( set -o allexport && source .env && set +o allexport && bin/storage-server run $$RUN_STORAGE_SERVER_ARGS )
|
|
|
|
.env:
|
|
cp .env.dist .env
|
|
|
|
gitea-release: tools/yq/bin/yq tools/gitea-release/bin/gitea-release.sh build
|
|
mkdir -p .gitea-release
|
|
rm -rf .gitea-release/*
|
|
|
|
cp bin/cli .gitea-release/edge_cli_amd64
|
|
|
|
# Create client-sdk-testsuite package
|
|
tools/yq/bin/yq -i '.version = "$(FULL_VERSION)"' ./misc/client-sdk-testsuite/dist/manifest.yml
|
|
.gitea-release/edge_cli_amd64 app package -d ./misc/client-sdk-testsuite/dist -o .gitea-release
|
|
|
|
GITEA_RELEASE_PROJECT="edge" \
|
|
GITEA_RELEASE_ORG="arcad" \
|
|
GITEA_RELEASE_BASE_URL="https://forge.cadoles.com" \
|
|
GITEA_RELEASE_VERSION="$(FULL_VERSION)" \
|
|
GITEA_RELEASE_NAME="$(FULL_VERSION)" \
|
|
GITEA_RELEASE_COMMITISH_TARGET="$(GIT_VERSION)" \
|
|
GITEA_RELEASE_IS_DRAFT="false" \
|
|
GITEA_RELEASE_IS_PRERELEASE="true" \
|
|
GITEA_RELEASE_BODY="" \
|
|
GITEA_RELEASE_ATTACHMENTS="$$(find .gitea-release/* -type f)" \
|
|
tools/gitea-release/bin/gitea-release.sh
|
|
|
|
tools/gitea-release/bin/gitea-release.sh:
|
|
mkdir -p tools/gitea-release/bin
|
|
curl --output tools/gitea-release/bin/gitea-release.sh https://forge.cadoles.com/Cadoles/Jenkins/raw/branch/master/resources/com/cadoles/gitea/gitea-release.sh
|
|
chmod +x tools/gitea-release/bin/gitea-release.sh
|
|
|
|
tools/yq/bin/yq:
|
|
mkdir -p tools/yq/bin
|
|
curl -L --output tools/yq/bin/yq https://github.com/mikefarah/yq/releases/download/v4.31.1/yq_linux_amd64
|
|
chmod +x tools/yq/bin/yq
|
|
|
|
tools/modd/bin/modd:
|
|
mkdir -p tools/modd/bin
|
|
GOBIN=$(PWD)/tools/modd/bin go install -mod=readonly github.com/cortesi/modd/cmd/modd@latest
|