release: v0.1.1 — ajoute make publish/deploy (Release Gitea)
L'APK était committé directement sur main sous un nom fixe (DataControl-0.1.0.apk, jamais renommé malgré des rebuilds répétés), gonflant l'historique de copies quasi identiques. Ajoute une publication propre via Gitea Releases, comme les autres apps Android du même auteur. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SUfjgGrqcTgjKQDAjD6vbA
This commit is contained in:
@@ -9,9 +9,14 @@ APK_RELEASE := app/build/outputs/apk/release/app-release.apk
|
||||
APK_DEBUG := app/build/outputs/apk/debug/app-debug.apk
|
||||
OUTPUT_APK := DataControl-$(VERSION_NAME).apk
|
||||
|
||||
GITEA_URL := https://git.tuxtech.fr
|
||||
GITEA_OWNER := tuxgyver
|
||||
GITEA_REPO_NAME := DataControl
|
||||
GITEA_TOKEN ?= $(shell sed -n 's/^giteaToken=//p' gitea-token.properties 2>/dev/null | tr -d '[:space:]')
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
.PHONY: help build release install push version-bump changelog clean
|
||||
.PHONY: help build release install push version-bump changelog clean tag _check-token _check-apk publish deploy
|
||||
|
||||
## help: Show this help message
|
||||
help:
|
||||
@@ -49,6 +54,68 @@ push:
|
||||
git push origin "v$(VERSION_NAME)"
|
||||
@echo "[PUSH] Done."
|
||||
|
||||
## tag: Create and push the git tag for the current version
|
||||
tag:
|
||||
@if git rev-parse "v$(VERSION_NAME)" >/dev/null 2>&1; then \
|
||||
echo "Tag v$(VERSION_NAME) already exists, skipping"; \
|
||||
else \
|
||||
git diff --quiet || { echo "Working tree not clean — commit first (version.properties, CHANGELOG.md, …)"; exit 1; }; \
|
||||
echo "Tag: v$(VERSION_NAME)"; \
|
||||
git tag -a "v$(VERSION_NAME)" -m "Release v$(VERSION_NAME)"; \
|
||||
fi
|
||||
@git push origin "v$(VERSION_NAME)"
|
||||
@echo "Tag v$(VERSION_NAME) pushed"
|
||||
|
||||
_check-token:
|
||||
@test -n "$(GITEA_TOKEN)" || \
|
||||
(echo "GITEA_TOKEN missing. Create gitea-token.properties (giteaToken=…) or export GITEA_TOKEN." && exit 1)
|
||||
|
||||
_check-apk:
|
||||
@test -f $(OUTPUT_APK) || \
|
||||
(echo "$(OUTPUT_APK) not found — run 'make release' first." && exit 1)
|
||||
@test $(OUTPUT_APK) -nt version.properties || \
|
||||
(echo "$(OUTPUT_APK) is older than version.properties — rerun 'make release'." && exit 1)
|
||||
|
||||
## publish: Publish the signed APK as a Gitea Release (tag + assets, idempotent)
|
||||
publish: _check-apk _check-token tag
|
||||
@echo "Publishing Gitea release v$(VERSION_NAME)…"
|
||||
@EXISTING=$$(curl -s -H "Authorization: token $(GITEA_TOKEN)" \
|
||||
"$(GITEA_URL)/api/v1/repos/$(GITEA_OWNER)/$(GITEA_REPO_NAME)/releases/tags/v$(VERSION_NAME)"); \
|
||||
REL_ID=$$(printf '%s\n' "$$EXISTING" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['id'] if isinstance(d, dict) and 'id' in d else '')" 2>/dev/null); \
|
||||
if [ -n "$$REL_ID" ]; then \
|
||||
echo "Release v$(VERSION_NAME) already published (id=$$REL_ID), reusing"; \
|
||||
else \
|
||||
BODY=$$(awk -v ver="v$(VERSION_NAME)" '$$0 ~ "^## " ver {f=1; next} f && /^## /{exit} f{print}' CHANGELOG.md | \
|
||||
python3 -c "import sys,json; print(json.dumps(sys.stdin.read().strip()))"); \
|
||||
RESP=$$(curl -s -X POST \
|
||||
-H "Authorization: token $(GITEA_TOKEN)" \
|
||||
-H "Content-Type: application/json" \
|
||||
"$(GITEA_URL)/api/v1/repos/$(GITEA_OWNER)/$(GITEA_REPO_NAME)/releases" \
|
||||
-d "{\"tag_name\":\"v$(VERSION_NAME)\",\"name\":\"v$(VERSION_NAME)\",\"body\":$$BODY,\"draft\":false,\"prerelease\":false}"); \
|
||||
REL_ID=$$(printf '%s\n' "$$RESP" | python3 -c "import sys,json; print(json.load(sys.stdin).get('id',''))" 2>/dev/null); \
|
||||
if [ -z "$$REL_ID" ]; then echo "Error creating release: $$RESP"; exit 1; fi; \
|
||||
echo "Release created (id=$$REL_ID)"; \
|
||||
fi; \
|
||||
OLD_ASSET=$$(curl -s -H "Authorization: token $(GITEA_TOKEN)" \
|
||||
"$(GITEA_URL)/api/v1/repos/$(GITEA_OWNER)/$(GITEA_REPO_NAME)/releases/$$REL_ID" | \
|
||||
python3 -c "import sys,json; a=[x['id'] for x in json.load(sys.stdin)['assets'] if x['name']=='$(OUTPUT_APK)']; print(a[0] if a else '')" 2>/dev/null); \
|
||||
if [ -n "$$OLD_ASSET" ]; then \
|
||||
curl -s -X DELETE -H "Authorization: token $(GITEA_TOKEN)" \
|
||||
"$(GITEA_URL)/api/v1/repos/$(GITEA_OWNER)/$(GITEA_REPO_NAME)/releases/$$REL_ID/assets/$$OLD_ASSET" > /dev/null; \
|
||||
fi; \
|
||||
echo "Uploading $(OUTPUT_APK)…"; \
|
||||
UPRESP=$$(curl -s -X POST -H "Authorization: token $(GITEA_TOKEN)" \
|
||||
"$(GITEA_URL)/api/v1/repos/$(GITEA_OWNER)/$(GITEA_REPO_NAME)/releases/$$REL_ID/assets" \
|
||||
-F "attachment=@$(OUTPUT_APK)"); \
|
||||
UP_ID=$$(printf '%s\n' "$$UPRESP" | python3 -c "import sys,json; print(json.load(sys.stdin).get('id',''))" 2>/dev/null); \
|
||||
if [ -z "$$UP_ID" ]; then echo "Error uploading APK: $$UPRESP"; exit 1; fi; \
|
||||
echo "APK uploaded"; \
|
||||
echo ""; \
|
||||
echo "$(GITEA_URL)/$(GITEA_OWNER)/$(GITEA_REPO_NAME)/releases/tag/v$(VERSION_NAME)"
|
||||
|
||||
## deploy: Build the signed APK then publish (commit source changes first!)
|
||||
deploy: release publish
|
||||
|
||||
## version-bump: Increment versionCode and update versionName patch
|
||||
version-bump:
|
||||
@NEW_CODE=$$(( $(VERSION_CODE) + 1 )); \
|
||||
|
||||
Reference in New Issue
Block a user