Android 开发 利用 jq 在 Makefile 里给 output-metadata.json 增加字段

Makefile:


.PHONY: upload
upload: metadata
	#./push-apk.sh


.PHONY: metadata
metadata: app/build/outputs/apk/release/output-metadata.json


app/build/outputs/apk/release/output-metadata.json: build update-content.txt
	# 在 Makefile 中插入shell脚本要用双美元符号($$)来引用变量
	apkSize=$$(du -b app/build/outputs/apk/release/*.apk | awk '{print $$1}');          \
	apkMd5=$$(openssl md5 app/build/outputs/apk/release/*.apk | awk '{print $$2}');     \
	jq '. += {updateContent: $$content}' $@ --arg content "$$(<update-content.txt)"     \
	| jq '.elements[0] += {apkFileSize: $$apk_file_size | tonumber, apkMd5: $$apk_md5}' \
	  --arg apk_file_size $$apkSize                                                     \
	  --arg apk_md5 $$apkMd5                                                            \
	> $@.tmp

	mv $@.tmp $@

.PHONY: build
build:
	./gradlew build

.PHONY: aab
aab:
	./gradlew bundle


.DEFAULT_GOAL := metadata

update-content.txt:

- Minor performance improvements and bug fixes
- add some features

posted on 2023-05-11 14:22  明天有风吹  阅读(183)  评论(0编辑  收藏  举报

导航

+V atob('d2h5X251bGw=')

请备注:from博客园