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 8 commits into
base: main
Choose a base branch
from
52 changes: 52 additions & 0 deletions .github/workflows/generate-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: vscode-generate-changelog

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to generate the changlog for'
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description: 'Branch to generate the changlog for'
description: 'Branch to generate the changelog for'

required: true
default: 'main'
type: string

jobs:
changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Generate changelog
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 left this as empty, it will group all categories in the PRs?

CHANGELOG_SKIP_NO_CHANGELOG: "true"
CHANGELOG_COMPACT: "true"
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)
export RELEASE_LATEST_RELEASE=$(git rev-parse $PREV_TAG)

# Get current release commit
export RELEASE_LATEST_COMMIT=$(git rev-parse HEAD)

# Download and run changelog generator
tagName=$(gh release -R sourcegraph/devx-service list --exclude-drafts --exclude-pre-releases -L 1 --json tagName -q '.[] | .tagName')
gh release -R sourcegraph/devx-service download ${tagName} --pattern changelog
chmod +x changelog

./changelog write \
--output-file="vscode/CHANGELOG.md" \
--output.changelog.marker='{/* CHANGELOG_START */}' \
--releaseregistry.version=$EXT_VERSION

git checkout -b release/vscode-v$EXT_VERSION
git add vscode/CHANGELOG.md
git commit -m "Automated release and changelog for VS code Cody"
git push -u origin release/vscode-v$EXT_VERSION
gh pr create \
--title "VS Code: Release v$EXT_VERSION" \
--body "Automated release and changelog for VS code Cody" \
--base main --head release/vscode-v$EXT_VERSION
62 changes: 60 additions & 2 deletions .github/workflows/vscode-stable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,64 @@ jobs:
asset_path: ./vscode/dist/cody.vsix
asset_name: cody-vscode-${{ env.EXT_VERSION }}.vsix
asset_content_type: application/zip
- name: Generate changelog
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can remove this step now right, and have the generate changelog manually be run

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?

CHANGELOG_SKIP_NO_CHANGELOG: "true"
CHANGELOG_COMPACT: "true"
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

export RELEASE_LATEST_RELEASE=$(git rev-parse $PREV_TAG)

# Get current release commit
export RELEASE_LATEST_COMMIT=$GITHUB_SHA
Chickensoupwithrice marked this conversation as resolved.
Show resolved Hide resolved

# Download and run changelog generator
tagName=$(gh release -R sourcegraph/devx-service list --exclude-drafts --exclude-pre-releases -L 1 --json tagName -q '.[] | .tagName')
gh release -R sourcegraph/devx-service download ${tagName} --pattern changelog
chmod +x changelog

./changelog write \
--output-file="raw-changelog.md" \
--releaseregistry.version=$EXT_VERSION

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

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!

git checkout -b release/vscode-v$EXT_VERSION
git add vscode/CHANGELOG.md
git commit -m "Automated release and changelog for VS code Cody"
git push -u origin release/vscode-v$EXT_VERSION
gh pr create \
--title "VS Code: Release v$EXT_VERSION" \
--body "Automated release and changelog for VS code Cody" \
--base main --head release/vscode-v$EXT_VERSION
Chickensoupwithrice marked this conversation as resolved.
Show resolved Hide resolved
- name: Register on Releaseregistry
env:
EXT_VERSION: ${{ env.EXT_VERSION }}
RELEASE_REGISTRY_TOKEN: ${{ secrets.RELEASE_REGISTRY_TOKEN }}
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!

"version": "'${EXT_VERSION}'",
"git_sha": "'${GITHUB_SHA}'"
}' "https://releaseregistry.sourcegraph.com/v1/releases")
exit_code=$?

if [ $exit_code != 0 ]; then
echo "❌ Failed to create release in release registry, got:"
echo "--- raw body ---"
echo $body
echo "--- raw body ---"
exit $exit_code
else
echo "Release created, see:"
echo $body
fi
- name: Determine version numbers
run: |
tag="${{ env.EXT_VERSION }}"
Expand Down Expand Up @@ -112,7 +170,7 @@ jobs:
echo "SKIP_BRANCH_CREATION=true" >> $GITHUB_ENV
exit 0
fi

# Check if label exists
if gh label list | grep -q "backport ${{ env.NEXT_RELEASE_BRANCH }}"; then
echo "Label backport ${{ env.NEXT_RELEASE_BRANCH }} already exists"
Expand All @@ -131,7 +189,7 @@ jobs:
repo: context.repo.repo,
name: `${nextBackportLabel}`,
description: `Backport to ${nextReleaseBranch} branch`
})
})
- name: Create and push next release branch
if: ${{ !env.SKIP_BRANCH_CREATION }}
run: |
Expand Down
2 changes: 2 additions & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

{/* CHANGELOG_START */}

## [Unreleased]

### Added
Expand Down
Loading