-
Notifications
You must be signed in to change notification settings - Fork 11
chore/add_tagging_script #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,9 @@ HTTPS_GIT := https://github.com/cosmos/cosmos-sdk.git | |||||||||||||||||||||||||||||||||||||
| DOCKER := $(shell which docker) | ||||||||||||||||||||||||||||||||||||||
| PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Subdirectories for tagging | ||||||||||||||||||||||||||||||||||||||
| SUBDIR_PREFIXES := api core errors store x/circuit x/evidence x/feegrant x/nft x/tx x/upgrade | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # process build tags | ||||||||||||||||||||||||||||||||||||||
| build_tags = netgo | ||||||||||||||||||||||||||||||||||||||
| ifeq ($(LEDGER_ENABLED),true) | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -481,3 +484,44 @@ localnet-start: localnet-stop localnet-build-env localnet-build-nodes | |||||||||||||||||||||||||||||||||||||
| localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| .PHONY: localnet-start localnet-stop localnet-debug localnet-build-env localnet-build-dlv localnet-build-nodes | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| ############################################################################### | ||||||||||||||||||||||||||||||||||||||
| ### Tagging ### | ||||||||||||||||||||||||||||||||||||||
| ############################################################################### | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # tag-client creates and pushes the special client tag with v2.0.0- prefix | ||||||||||||||||||||||||||||||||||||||
| # Usage: make tag-client TAG=v1.2.3 (creates client/v2.0.0-v1.2.3) | ||||||||||||||||||||||||||||||||||||||
| tag-client: | ||||||||||||||||||||||||||||||||||||||
| ifndef TAG | ||||||||||||||||||||||||||||||||||||||
| $(error TAG is required. Usage: make tag-client TAG=v1.2.3) | ||||||||||||||||||||||||||||||||||||||
| endif | ||||||||||||||||||||||||||||||||||||||
| @echo "Fetching latest tags from origin..." | ||||||||||||||||||||||||||||||||||||||
| @git fetch origin --tags | ||||||||||||||||||||||||||||||||||||||
| @echo "Creating client tag for $(TAG)..." | ||||||||||||||||||||||||||||||||||||||
| @client_tag="client/v2.0.0-$(TAG)"; \ | ||||||||||||||||||||||||||||||||||||||
| echo "Creating tag: $$client_tag"; \ | ||||||||||||||||||||||||||||||||||||||
| git tag "$$client_tag" $(TAG); \ | ||||||||||||||||||||||||||||||||||||||
| echo "Pushing tag: $$client_tag"; \ | ||||||||||||||||||||||||||||||||||||||
| git push origin "$$client_tag" | ||||||||||||||||||||||||||||||||||||||
| @echo "Successfully created and pushed client tag for $(TAG)" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # tag-subdirs creates and pushes tags with subdir prefixes for a given tag | ||||||||||||||||||||||||||||||||||||||
| # Usage: make tag-subdirs TAG=v1.2.3 | ||||||||||||||||||||||||||||||||||||||
| # NOTE: This also automatically creates the special client tag | ||||||||||||||||||||||||||||||||||||||
| tag-subdirs: tag-client | ||||||||||||||||||||||||||||||||||||||
| ifndef TAG | ||||||||||||||||||||||||||||||||||||||
| $(error TAG is required. Usage: make tag-subdirs TAG=v1.2.3) | ||||||||||||||||||||||||||||||||||||||
| endif | ||||||||||||||||||||||||||||||||||||||
| @echo "Fetching latest tags from origin..." | ||||||||||||||||||||||||||||||||||||||
| @git fetch origin --tags | ||||||||||||||||||||||||||||||||||||||
| @echo "Creating and pushing subdir tags for $(TAG)..." | ||||||||||||||||||||||||||||||||||||||
| @for prefix in $(SUBDIR_PREFIXES); do \ | ||||||||||||||||||||||||||||||||||||||
| new_tag="$$prefix/$(TAG)"; \ | ||||||||||||||||||||||||||||||||||||||
| echo "Creating tag: $$new_tag"; \ | ||||||||||||||||||||||||||||||||||||||
| git tag "$$new_tag" $(TAG); \ | ||||||||||||||||||||||||||||||||||||||
| echo "Pushing tag: $$new_tag"; \ | ||||||||||||||||||||||||||||||||||||||
| git push origin "$$new_tag"; \ | ||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+518
to
+524
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Handle pre-existing sub-dir tags to make the rule idempotent Running the rule twice currently hard-fails on - new_tag="$$prefix/$(TAG)"; \
- echo "Creating tag: $$new_tag"; \
- git tag "$$new_tag" $(TAG); \
- echo "Pushing tag: $$new_tag"; \
- git push origin "$$new_tag"; \
+ new_tag="$$prefix/$(TAG)"; \
+ if git rev-parse -q --verify "$$new_tag" >/dev/null; then \
+ echo "Tag $$new_tag already exists – skipping"; \
+ else \
+ echo "Creating tag: $$new_tag"; \
+ git tag -a "$$new_tag" -m "Auto-generated subdir tag for $$prefix $(TAG)" $(TAG); \
+ echo "Pushing tag: $$new_tag"; \
+ git push origin "$$new_tag"; \
+ fi; \This keeps the target repeatable and prevents accidental failures in CI. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| @echo "Successfully created and pushed all subdir tags for $(TAG)" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| .PHONY: tag-subdirs tag-client | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tag-clientis not idempotent and lacks basic validationRunning the target twice hard-fails (
git tag/git push), and it will happily create a tag even when$(TAG)is missing locally / remotely.Benefits: repeatable runs, clear error message, no local-branch pollution, traceable annotated tag.
📝 Committable suggestion
🤖 Prompt for AI Agents