Makefile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. VERS_MAJOR := 0
  2. VERS_MINOR := 5
  3. VERSION := $(VERS_MAJOR).$(VERS_MINOR)
  4. NEW_MINOR := $$(( $(VERS_MINOR) + 1 ))
  5. NEW_MAJOR := $$(( $(VERS_MAJOR) + 1 ))
  6. GITEA_URL := https://git.abbiamoundominio.org
  7. output:
  8. output/sendmail: output
  9. go build -o output/sendmail -ldflags "-X main.version=$(VERSION)" ./...
  10. output/sendmail-dev: output
  11. go build -o output/sendmail-dev ./...
  12. clean:
  13. rm -f output/*
  14. build: clean output/sendmail
  15. docker-build:
  16. docker build --build-arg=version=$(VERSION) -t leophys/mailer:$(VERSION) .
  17. dev-build: clean output/sendmail-dev
  18. bumpvers-minor:
  19. sed -i"" "s/VERS_MINOR := $(VERS_MINOR)/VERS_MINOR := $(NEW_MINOR)/" Makefile
  20. git add Makefile
  21. git commit -m "Bump version $(VERSION) -> $(VERS_MAJOR).$(NEW_MINOR)"
  22. git tag $(VERS_MAJOR).$(NEW_MINOR)
  23. bumpvers-major:
  24. sed -i"" "s/VERS_MAJOR := $(VERS_MAJOR)/VERS_MAJOR := $$(( $(VERS_MAJOR) + 1 ))/" Makefile
  25. git add Makefile
  26. git commit -m "Bump version $(VERSION) -> $(NEW_MAJOR).$(VERS_MINOR)"
  27. git tag $(NEW_MAJOR).$(VERS_MINOR)
  28. new-release:
  29. last_tag=$$(git tag|tail -n2|head -n1); \
  30. release_id=$$(curl -X POST \
  31. "$(GITEA_URL)/api/v1/repos/blallo/sendmail/releases" \
  32. -H "Authorization: token $$(cat .token)" \
  33. -H "accept: application/json" \
  34. -H "Content-Type: application/json" \
  35. -d "{\"body\": \"$$(git log $${last_tag}..HEAD~)\", \"draft\": false, \"name\": \"$(VERSION)\", \"prerelease\": false, \"tag_name\": \"$(VERSION)\", \"target_commitish\": \"$$(git rev-parse HEAD)\" }") \
  36. | jq '.id'; \
  37. curl -X POST \
  38. "$(GITEA_URL)/api/v1/repos/blallo/sendmail/releases/$${release_id}/assets?name=sendmail" \
  39. -H "Authorization: token $$(cat .token)" \
  40. -H "accept: application/json" \
  41. -H "Content-Type: multipart/form-data" \
  42. -F "attachment=@output/sendmail"
  43. release-min:
  44. make bumpvers-minor
  45. make build
  46. make docker-build
  47. git push
  48. git push --tags
  49. make new-release
  50. release-maj:
  51. make bumpvers-major
  52. make build
  53. make docker-build
  54. git push
  55. git push --tags
  56. make new-release
  57. PHONY: bumpvers-minor bumpvers-major release-min release-maj clean docker-build new-release