Skip to content
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

[LANGPLAT-87] Implement automated release tagging for dd-trace-go v2 #3159

Draft
wants to merge 1 commit into
base: v2-dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ use (
./internal/exectracetest
./internal/setup-smoke-test
./internal/traceprof/traceproftest
./tools/autoreleasetagger
./tools/fixmodules
./tools/v2check
./tools/v2check/_stage
Expand Down
3 changes: 3 additions & 0 deletions tools/autoreleasetagger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tmp
autoreleasetagger
main
33 changes: 33 additions & 0 deletions tools/autoreleasetagger/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.PHONY: fmt
fmt:
go run mvdan.cc/gofumpt@latest -l -w .

.PHONY: vet
vet:
GOWORK=off go vet ./...

.PHONY: fix
fix: build
GOWORK=off golangci-lint run --fix --enable-all --no-config ./...

.PHONY: lint
lint:
GOWORK=off golangci-lint run --enable-all --no-config ./...

.PHONY: test
test: deps
GOWORK=off go test -v ./...

deps:
go mod tidy

.PHONY: build
build: deps
go build -o autoreleasetagger ./main.go

tmp/help.txt: build
./autoreleasetagger -h > tmp/help.txt 2>&1

.PHONY: README.md
README.md: tmp/help.txt
go run github.com/campoy/embedmd@latest -w README.md
91 changes: 91 additions & 0 deletions tools/autoreleasetagger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Auto Release Tagger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up top can we also specify when you would use this tool? It's during the release process? And what is this new tool affording us that we did not have previously (with the old release process)?


This tool ensures that all modules in a monorepo are tagged correctly, respecting dependency order—tagging dependencies first before their dependents.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this sentence hard to read, maybe you mean this instead?

Suggested change
This tool ensures that all modules in a monorepo are tagged correctly, respecting dependency ordertagging dependencies first before their dependents.
This tool ensures that all modules in a monorepo are tagged correctly, respecting dependency order by tagging dependencies first before their dependents.

?


- **Automatic Versioning**: Determines the next version based on existing tags.
- **Nested Module Support**: Tags all modules in a repository.
- **Dependency Awareness**: Ensures dependencies are tagged before their dependents.

## 📌 Prerequisites

Before running the tool, ensure you have updated the version according to the [Release Checklist](https://datadoghq.atlassian.net/wiki/spaces/DL/pages/2477949158/Template+v+MAJOR+.+MINOR+.+PATCH+Release+Checklist#Release-branch).

## 🛠️ Usage

Run the following command to tag the release:

```sh
go run ./tools/autoreleasetagger -root ../..
```

Dry run:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to see a quick statement about when/why you would do a Dry Run instead of a regular run, so that a reader can decide the correct use case for this command.
e.g.
Dry run: Simulate the tagging process to check for potential issues


```sh
go run ./tools/autoreleasetagger -dry-run -root ../..
```

Run without pushing tags:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as Dry Run. Admittedly, commenting that because I at first had to think critically about why you might want to do those operations.


```sh
go run ./tools/autoreleasetagger -disable-push -root ../..
```

## 📖 Help

[embedmd]:# (tmp/help.txt)
```txt
Usage of ./autoreleasetagger:
-disable-push
Disable pushing tags to remote
-dry-run
Enable dry run mode (skip actual operations)
-exclude-dirs string
Comma-separated list of directories to exclude. Paths are relative to the root directory
-exclude-modules string
Comma-separated list of modules to exclude
-loglevel string
Log level (debug, info, warn, error) (default "info")
-remote string
Git remote name (default "origin")
-root string
Path to the root directory (required)
```


## 🚀 Development

### Helpful Commands for Cleaning Up

```sh
export GIT_REMOTE=${GIT_REMOTE:-origin}

# List local-only tags
git tag -l | grep -v "$(git ls-remote --tags $GIT_REMOTE | sed 's/.*refs\/tags\///g')"

# Remove local-only tags
git tag -l | grep -v "$(git ls-remote --tags $GIT_REMOTE | sed 's/.*refs\/tags\///g')" | xargs git tag -d
```

#### Git Alias Setup

```sh
export GIT_REMOTE=${GIT_REMOTE:-origin}

# List tags that exist only locally
git config --global alias.list-local-tags "!git tag -l | grep -v \"$(git ls-remote --tags $GIT_REMOTE | sed 's/.*refs\/tags\///g')\""

# Remove tags that exist only locally
git config --global alias.remove-local-tags "!git tag -l | grep -v \"$(git ls-remote --tags $GIT_REMOTE | sed 's/.*refs\/tags\///g')\" | xargs git tag -d"
```

**Usage**

```sh
export GIT_REMOTE=${GIT_REMOTE:-origin}

# List local-only tags
git list-local-tags

# Remove local-only tags
git remove-local-tags
```
5 changes: 5 additions & 0 deletions tools/autoreleasetagger/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/DataDog/dd-trace-go/v2/tools/autoreleasetagger

go 1.22.0

require github.com/DataDog/dd-trace-go/v2 v2.0.0-rc.2
2 changes: 2 additions & 0 deletions tools/autoreleasetagger/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/DataDog/dd-trace-go/v2 v2.0.0-rc.2 h1:V9IEiUjs5+ye8xTReLo2KS/P4j0HvwS+YJXhRnmmDDY=
github.com/DataDog/dd-trace-go/v2 v2.0.0-rc.2/go.mod h1:5heIdFEknx0pqz3WykyjDo/aMaxjkd8bMySlHPDj6jA=
Loading
Loading