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

release: changelog generator + releaseregistry registration #6243

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Chickensoupwithrice
Copy link
Contributor

This PR adds two more steps to the GHA release pipeline:

  • Generate a Changelog, and PR it
  • Register the release on the releaseregistry

Adding Cody to the releaseregistry allows us to integrate the changelog through that mechanism, but since no data is currently backported, we're using Git to determine previous release commit hashes in order to generate the new changelog.

Test plan

Run the CI pipeline 😬

Changelog

N/A

The changelog generator doesn't like overwriting existing files, so we
write it to a different file and then append the old changelog to the
newly generated file. Then we replace the old changelog with the new
one.

I tested this locally with the script (attached below for completeness).
However in order to run the script, I built and copied the changelog
generator from the devx service manually with Bazel, since the download
only has binaries for linux.

I came across a bug in the changelog generation where it doesn't accept
the `github.token` flag when passed, but it will pick up the `GH_TOKEN`
env var, so that's what I ended up using for testing. I _believe_ that
this token is set by default in github actions, but am not certain.

Test script:
```

PREV_TAG=$(git tag --sort=-v:refname | grep '^vscode-v' | head -n 2 | tail -n 1)
RELEASE_LATEST_RELEASE=$(git rev-parse "$PREV_TAG")
export RELEASE_LATEST_RELEASE

export RELEASE_LATEST_COMMIT="1c6bc9563c39724e5248e0524017f41331f5bc64"

export GH_TOKEN="CENSORED_REPLACE_ME_WITH_REAL_TOKEN"

./changelog write \
  --output-file="new-changelog.md" \
  --github.repo="sourcegraph/cody" \
  --releaseregistry.version="1.48.0"

cat vscode/CHANGELOG.md >>new-changelog.md
mv new-changelog.md CHANGELOG.md
```
@Chickensoupwithrice Chickensoupwithrice marked this pull request as ready for review December 6, 2024 21:47
Copy link

@jdpleiness jdpleiness left a comment

Choose a reason for hiding this comment

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

Looks like there are still some merge conflicts and CI is still running for some reason? 🤔

Comment on lines +96 to +97
cat vscode/CHANGELOG.md >> raw-changelog.md
mv raw-changelog.md vscode/CHANGELOG.md

Choose a reason for hiding this comment

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

🤔 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changelog generator doesn't do "prepend" to file for existing changelogs. We're doing that part by hand in the shell file.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you provide a sample of what raw-changelog.md will look like?

maybe instead of appending the entire vscode/changelog.md into raw-changelog, we can find a spot within vscode/changelog.md and append under it

Example, this is what the current first 20 lines of vscode/changelog.md looks like:

# Changelog

This is a log of all notable changes to Cody for VS Code.

## Unreleased

### Added

### Fixed

### Changed

### Uncategorized

## 1.50.0

### Added
- Webviews: add new CTA for Sourcegraph Teams  [pull/6245](https://github.com/sourcegraph/cody/pull/6245)
- "Explain command" in context (existing conversation)  [pull/5986](https://github.com/sourcegraph/cody/pull/5986)

depending on what raw-changelog.md looks like, we could just append it right under ### uncategorized using

awk '/### Uncategorized/{if (!found) {print; system("cat raw_changelog.md"); found=1; next}} 1' vscode/CHANGELOG.md > temp_changelog.md

# Replace original file with new content
mv temp_changelog.md vscode/CHANGELOG.md

maybe we can pair on this to be clear!

run: |
echo "Registering internal cody-vscode $EXT_VERSION release on release registry"
body=$(wget --content-on-error -O- --header="Content-Type: application/json" --header="Authorization: ${RELEASE_REGISTRY_TOKEN}" --post-data '{
"name": "cody-vscode",

Choose a reason for hiding this comment

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

Do we have this type in the release registry already?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it's new!

@Chickensoupwithrice
Copy link
Contributor Author

Yeah, CI on this repo is questionable, it's not expected to pass generally.

EXT_VERSION: ${{ env.EXT_VERSION }}
run: |
# Get previous tag's commit
PREV_TAG=$( git tag --sort=-v:refname | grep '^vscode-v' | head -n 2 | tail -n 1)

Choose a reason for hiding this comment

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

Does this assume we've already registered our new release version? i.e.

vscode-v1.2.3
vscode-v1.2.2
vscode-v1.2.1
This would return 'vscode-v1.2.2'

Why are we selecting that one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, for me this returns vscode-v1.46.0 which is currently the latest release, which is what we're trying to get. Once the releaseregistry is hooked up and has a bit of data, we can switch to using that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The list, without taking the second element exclusively, on my machine is:
image

@kalanchan
Copy link
Contributor

will review this tomorrow, thanks for all the progress here my @sourcegraph/release boys 🫡

Copy link
Contributor

@kalanchan kalanchan left a comment

Choose a reason for hiding this comment

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

thank you so much @Chickensoupwithrice !!!! I left some comments, I think we should pull the changelog generator into a separate workflow.

i'll set up some time to pair with you to land this, but the direction is really good!

env:
DEVX_SERVICE_GH_TOKEN: ${{ secrets.DEVX_SERVICE_GH_TOKEN }}
GH_REPO: "sourcegraph/cody"
CHANGELOG_CATEGORY_ACCEPTLIST: "added,changed,fixed"
Copy link
Contributor

Choose a reason for hiding this comment

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

if we leave this blank, will the tooling accept and group all categories?

.github/workflows/vscode-stable-release.yml Show resolved Hide resolved
Comment on lines +96 to +97
cat vscode/CHANGELOG.md >> raw-changelog.md
mv raw-changelog.md vscode/CHANGELOG.md
Copy link
Contributor

Choose a reason for hiding this comment

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

can you provide a sample of what raw-changelog.md will look like?

maybe instead of appending the entire vscode/changelog.md into raw-changelog, we can find a spot within vscode/changelog.md and append under it

Example, this is what the current first 20 lines of vscode/changelog.md looks like:

# Changelog

This is a log of all notable changes to Cody for VS Code.

## Unreleased

### Added

### Fixed

### Changed

### Uncategorized

## 1.50.0

### Added
- Webviews: add new CTA for Sourcegraph Teams  [pull/6245](https://github.com/sourcegraph/cody/pull/6245)
- "Explain command" in context (existing conversation)  [pull/5986](https://github.com/sourcegraph/cody/pull/5986)

depending on what raw-changelog.md looks like, we could just append it right under ### uncategorized using

awk '/### Uncategorized/{if (!found) {print; system("cat raw_changelog.md"); found=1; next}} 1' vscode/CHANGELOG.md > temp_changelog.md

# Replace original file with new content
mv temp_changelog.md vscode/CHANGELOG.md

maybe we can pair on this to be clear!

.github/workflows/vscode-stable-release.yml Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants