Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (103 loc) · 6.09 KB
/
Copy pathMakefile
File metadata and controls
123 lines (103 loc) · 6.09 KB
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
PROJECT := src/PrinterControl
MANIFEST := $(PROJECT)/manifest.json
STATE := $(PROJECT)/.macrodeck-dev-state
UTF8 := $(if $(filter Windows_NT,$(OS)),chcp.com 65001 >/dev/null &&)
RUN := $(UTF8) macrodeck-plugin run --project $(PROJECT) --state-directory $(STATE)
# The SDK version, for keeping the macrodeck-plugin CLI in step. Read inside recipes rather than with
# $(shell): GnuWin32's make 3.81 sometimes runs $(shell) with an empty command line.
SDK := grep 'MacroDeckSdkVersion Condition' Directory.Packages.props | cut -d'>' -f2 | cut -d'<' -f1
TESTS := dotnet test PrinterControl.slnx --configuration Release
RID := $(if $(filter Windows_NT,$(OS)),win-x64,$(if $(filter Linux,$(shell uname -s)),linux-x64,osx-arm64))
# Shared by pack and release. release must not call $(MAKE): make runs such a line even under -n.
PACK := rm -f artifacts/*.macroDeckPlugin && \
macrodeck-plugin build --source $(PROJECT) --rid $(RID) --output ./artifacts && \
macrodeck-plugin inspect --artifact "$$(ls artifacts/*.macroDeckPlugin)"
# Store images: every [UiPreview] scenario at each deck shape. Override on the command line,
# e.g. make preview CELLS="--cells 2x2" PREVIEW_ARGS="--theme light". STORE=1 then pads each one onto a
# 16:9 canvas, the shape the store crops card artwork to.
CELLS := --cells 1x1 --cells 2x1 --cells 2x2
PREVIEWS := artifacts/previews
# An unreleased SDK: a Macro Deck checkout packed into local-feed/, built with -p:MacroDeckSdkVersion=$(LOCAL_SDK).
MACRODECK ?= ../Macro-Deck
LOCAL_SDK ?= 3.0.0-local.1
SDK_PROJECTS := protocol/src/MacroDeck.Plugin.Protocol ui-model/src/MacroDeck.Ui.Model ui-model/src/MacroDeck.Ui \
sdk/src/MacroDeck.Localization sdk/src/MacroDeck.Sdk sdk/src/MacroDeck.Plugin.Analyzers \
sdk/src/MacroDeck.Plugin.Packaging sdk/src/MacroDeck.Plugin.Hosting sdk/src/MacroDeck.Plugin.Serilog \
sdk/src/MacroDeck.Plugin.Testing
.DEFAULT_GOAL := help
.PHONY: help cli build test run watch stub preview pack conformance update release local-sdk
help:
@echo "make cli install/update the macrodeck-plugin CLI to the SDK version ($$($(SDK)))"
@echo "make build build the solution"
@echo "make test unit and end-to-end tests, as the release workflow runs them"
@echo "make run run the plugin against the running Macro Deck"
@echo "make watch the same, with hot reload / restart on every saved change"
@echo "make stub run the plugin against a disposable stub host (no Macro Deck needed)"
@echo "make preview [STORE=1]"
@echo " render the widget previews to PNGs in $(PREVIEWS)/ (store images; STORE=1 pads to 16:9)"
@echo "make pack build this platform's .macroDeckPlugin ($(RID)) into artifacts/ and inspect it"
@echo "make conformance run the conformance suite, report in conformance.md"
@echo "make local-sdk pack the SDK from a Macro Deck checkout (MACRODECK=$(MACRODECK)) into local-feed/"
@echo "make update bump every package to its newest release (review the diff)"
@echo "make release [VERSION=x.y.z]"
@echo " test + pack, bump manifest.json only if VERSION differs, tag, push"
cli:
dotnet tool update --global MacroDeck.Plugin.Cli --version "$$($(SDK))"
build:
dotnet build PrinterControl.slnx
test:
$(TESTS)
run:
$(RUN)
watch:
$(RUN) --watch
stub:
$(UTF8) macrodeck-plugin run --project $(PROJECT) --stub-host
preview:
rm -rf $(PREVIEWS)
$(UTF8) macrodeck-plugin preview render --project $(PROJECT) $(CELLS) --output $(PREVIEWS) $(PREVIEW_ARGS)
$(if $(STORE),dotnet run tools/StoreCanvas.cs -- $(PREVIEWS))
pack:
$(PACK)
conformance:
macrodeck-plugin test --project $(PROJECT) --report markdown --output conformance.md
local-sdk:
@test -d "$(MACRODECK)/sdk" || { echo "no Macro Deck checkout at $(MACRODECK)"; exit 1; }
for project in $(SDK_PROJECTS); do \
dotnet pack "$(MACRODECK)/$$project" -c Release -p:Version=$(LOCAL_SDK) -o "$(CURDIR)/local-feed" || exit 1; \
done
update:
dotnet package update
# Pushing the tag starts .github/workflows/release.yml, which checks the manifest version against the
# tag, creates the GitHub release and publishes to the Creator Portal. Without VERSION the manifest's own
# version is released as is; a VERSION that differs is bumped first. Everything that can fail runs before
# the bump commit, so a failed check leaves nothing to undo.
# Versions are ordered by git and awk: under cmd, sort can be Windows' sort.exe, which has no -V.
release:
@set -e; \
git pull --ff-only; \
current="$$(sed -n 's/^ "version": "\(.*\)",$$/\1/p' $(MANIFEST))"; \
version="$(VERSION)"; [ -n "$$version" ] || version="$$current"; \
case "$$version" in \
[0-9]*.[0-9]*.[0-9]*) ;; \
*) echo "usage: make release [VERSION=x.y.z] (manifest: $$current)"; exit 1 ;; \
esac; \
test "$$(git rev-parse --abbrev-ref HEAD)" = main || { echo "release from main only"; exit 1; }; \
test -z "$$(git status --porcelain)" || { echo "working tree is not clean"; exit 1; }; \
git fetch --tags --quiet origin; \
! git rev-parse -q --verify "refs/tags/v$$version" >/dev/null || { echo "tag v$$version already exists"; exit 1; }; \
latest="$$(git tag -l 'v[0-9]*' --sort=v:refname | tail -n 1 | sed 's/^v//')"; \
newer="$$(awk -v a="$$version" -v b="$$latest" 'BEGIN { split(a, x, "."); split(b, y, "."); for (i = 1; i <= 3; i++) if (x[i] + 0 != y[i] + 0) { print (x[i] + 0 > y[i] + 0 ? "yes" : "no"); exit } print "no" }')"; \
if [ -n "$$latest" ] && [ "$$newer" != yes ]; then \
echo "v$$version is not newer than the latest release v$$latest"; exit 1; \
fi; \
echo "releasing v$$version (latest release: v$${latest:-none}, manifest: $$current)"; \
$(TESTS); \
$(PACK); \
if [ "$$version" != "$$current" ]; then \
sed -i.bak 's/^ "version": ".*",$$/ "version": "'"$$version"'",/' $(MANIFEST); rm -f $(MANIFEST).bak; \
grep -q "^ \"version\": \"$$version\",$$" $(MANIFEST) || { echo "could not set the version in $(MANIFEST)"; git checkout -- $(MANIFEST); exit 1; }; \
git commit -m "chore: bump version to $$version" -- $(MANIFEST); \
fi; \
git tag "v$$version"; \
git push --atomic origin main "v$$version"