Skip to content

Commit 73ce2ac

Browse files
authored
Add portable sed handling and hash versioning for test deployments (#37)
Co-authored-by: Edward Delaporte (@edthedev) Co-authored-by: David Riddle (@ddriddle) Co-authored-by: Michelle Pitcel (@mpitcel) Co-authored-by: Zach Carrington (@zdc217) Co-authored-by: Tyler Turner (@tzturner) Co-authored-by: Elena Zheng (@ez720)
1 parent 873b2a8 commit 73ce2ac

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Makefile

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@ VERSIONED_FILES:=$(addprefix $(SRCS_DIR)/, $(PACKAGE).json app.py)
1717
BUILD_TIME:=$(shell date -u +%FT%X.%6NZ)
1818
VENV_PYTHON:=venv/bin/python
1919
VENV_REQS:=.requirements.venv
20+
UNAME:=$(shell uname)
21+
22+
ifeq ($(UNAME), Darwin)
23+
# macOS (BSD sed)
24+
SED_INPLACE := -i ''
25+
else
26+
# Linux and others (GNU sed)
27+
SED_INPLACE := -i
28+
endif
2029

2130
ifeq (tag, $(GITHUB_REF_TYPE))
2231
TAG?=$(GITHUB_REF_NAME)
2332
else
24-
TAG?=0.0.0
33+
TAG?=$(shell printf "0.0.%d" 0x$(shell git rev-parse --short=6 HEAD))
2534
endif
2635
GITHUB_SHA?=$(shell git rev-parse HEAD)
2736

@@ -46,22 +55,22 @@ $(PACKAGE).tar: src/app/bhr_client-1.6-py3-none-any.whl version $(SOAR_SRCS)
4655
version: .tag .commit .deployed
4756
.tag: $(VERSIONED_FILES)
4857
echo version $(TAG)
49-
sed -i "s/GITHUB_TAG/$(TAG)/" $^
58+
sed $(SED_INPLACE) "s/GITHUB_TAG/$(TAG)/" $^
5059
touch $@
5160
.commit: $(VERSIONED_FILES)
5261
echo commit $(GITHUB_SHA)
53-
sed -i "s/GITHUB_SHA/$(GITHUB_SHA)/" $^
62+
sed $(SED_INPLACE) "s/GITHUB_SHA/$(GITHUB_SHA)/" $^
5463
touch $@
5564
.deployed: $(VERSIONED_FILES)
5665
echo deployed $(BUILD_TIME)
57-
sed -i "s/BUILD_TIME/$(BUILD_TIME)/" $^
66+
sed $(SED_INPLACE) "s/BUILD_TIME/$(BUILD_TIME)/" $^
5867
touch $@
5968
.appjson: $(SRCS_DIR)/$(PACKAGE).json
6069
echo appid: $(APP_ID)
6170
echo name: $(APP_NAME)
62-
sed -i "s/APP_ID/$(APP_ID)/" $^
63-
sed -i "s/APP_NAME/$(APP_NAME)/" $^
64-
sed -i "s/MODULE/$(MODULE)/" $^
71+
sed $(SED_INPLACE) "s/APP_ID/$(APP_ID)/" $^
72+
sed $(SED_INPLACE) "s/APP_NAME/$(APP_NAME)/" $^
73+
sed $(SED_INPLACE) "s/MODULE/$(MODULE)/" $^
6574
touch $@
6675

6776
deploy: $(PACKAGE).tar
@@ -79,7 +88,7 @@ requirements-test.txt: requirements-test.in
7988
$(VENV_REQS)/bin/python -m pip install -r $^
8089
$(VENV_REQS)/bin/python -m pip freeze -qqq > $@
8190
#REMOVE once pytest-splunk-soar-connectors is on pypi
82-
sed -i "s;^pytest-splunk-soar-connectors==.*;$(PYTEST_SOAR_REPO);" $@
91+
sed $(SED_INPLACE) "s;^pytest-splunk-soar-connectors==.*;$(PYTEST_SOAR_REPO);" $@
8392

8493
lint: venv .lint
8594
.lint: $(SRCS) $(TSCS)

requirements-test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tomli==2.0.1
3131
types-beautifulsoup4==4.12.0.1
3232
types-html5lib==1.1.11.13
3333
types-requests==2.28.11.17
34-
types-urllib3==1.26.25.9
34+
types-urllib3==1.26.25.10
3535
typing_extensions==4.5.0
3636
urllib3==1.26.15
3737
vcrpy==4.2.1

0 commit comments

Comments
 (0)