-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
95 lines (77 loc) · 3.47 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
SHELL := /bin/bash
DEFAULT_VERSION=1.0.0
# Compile wasm game
compile-game:
cd src && \
clang \
--target=wasm32 \
-nostdlib \
-Wl,--no-entry \
-Wl,--allow-undefined \
-Wl,--strip-all \
-Wl,--export-dynamic \
-Os \
-fvisibility=hidden \
-Wl,--initial-memory=8388608 \
-Wl,--lto-O3 \
-Wl,-z,stack-size=1048576 \
-I ./system/ \
-I ./logic/ \
-o ../public/game.wasm \
main.c system/system*.c logic/game*.c
# Build game
build-game:
DOCKER_BUILDKIT=1 docker build --file Dockerfile.game --output ./src/view/src/assets .
# Build view
build-view:
DOCKER_BUILDKIT=1 docker build --file Dockerfile.view --output ./src/train_invaders .
# Build TrainInvaders
build: build-game build-view
# Install dependencies
install-deps:
@echo [!] Installing Semver
@sudo wget https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver -O /usr/bin/semver
@sudo chmod +x /usr/bin/semver
@echo [!] Installing yq
@sudo wget https://github.com/mikefarah/yq/releases/download/v4.6.1/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq
@echo [!] Installing Poetry
@sudo apt install python3-setuptools
@sudo pip3 install poetry --upgrade
# Scan dependencies for insecure packages.
dependencies-safety:
@sudo pip3 install safety
@poetry export --format=requirements.txt --without-hashes --output=requirements.txt
@safety check --file=requirements.txt --full-report
# Bump version
bump-version:
$(eval CURRENT_VERSION=$(shell git for-each-ref --sort=-v:refname --count=1 refs/tags/[0-9]*.[0-9]*.[0-9]* refs/tags/v[0-9]*.[0-9]*.[0-9]* | cut -d / -f 3-))
$(eval NEW_VERSION=v$(shell \
if [ -z $(CURRENT_VERSION) ]; then \
echo $(DEFAULT_VERSION); \
else \
semver bump patch $(CURRENT_VERSION); \
fi; \
))
@git log -1 --pretty="%B" > /tmp/commit-message
@sed -i '1s/^/\[$(NEW_VERSION)] /' /tmp/commit-message
@echo [!] Bumping version from $(CURRENT_VERSION) to $(NEW_VERSION)
@poetry version $(NEW_VERSION) || true
@git add pyproject.toml || true
git commit -F /tmp/commit-message --amend --no-edit
git tag -a -m "Version $(NEW_VERSION)" $(NEW_VERSION)
@BRANCH_PROTECTION=`curl https://api.github.com/repos/$(GITHUB_REPOSITORY)/branches/master/protection \
-H "Authorization: token $(CAMPARIBOT_TOKEN)" -H "Accept:application/vnd.github.luke-cage-preview+json" -X GET -s`; \
if [ "`echo $$BRANCH_PROTECTION | jq -r '.message'`" != "Branch not protected" ]; \
then \
echo [!] Disabling GitHub master branch protection; \
curl https://api.github.com/repos/$(GITHUB_REPOSITORY)/branches/master/protection \
-H "Authorization: token $(CAMPARIBOT_TOKEN)" -H "Accept:application/vnd.github.luke-cage-preview+json" -X DELETE; \
trap '\
echo [!] Re-enabling GitHub master branch protection; \
curl https://api.github.com/repos/$(GITHUB_REPOSITORY)/branches/master/protection -H "Authorization: token $(CAMPARIBOT_TOKEN)" \
-H "Accept:application/vnd.github.luke-cage-preview+json" -X PUT -d "{\"required_status_checks\":{\"strict\":false,\"contexts\":`echo $$BRANCH_PROTECTION | jq '.required_status_checks.contexts'`},\"restrictions\":{\"users\":[],\"teams\":[],\"apps\":[]},\"required_pull_request_reviews\":{\"dismiss_stale_reviews\":false,\"require_code_owner_reviews\":false},\"enforce_admins\":true,\"required_linear_history\":false,\"allow_force_pushes\":true,\"allow_deletions\":false}"; \
' EXIT; \
fi; \
echo [!] Git Push; \
git push --force;
echo "::set-output name=bumped_version_commit_hash::`git log --pretty=format:'%H' -n 1`";