diff --git a/.github/workflows/generate-changelog.yml b/.github/workflows/generate-changelog.yml new file mode 100644 index 000000000000..809fc33743f5 --- /dev/null +++ b/.github/workflows/generate-changelog.yml @@ -0,0 +1,53 @@ +name: vscode-generate-changelog + +on: + workflow_dispatch: + inputs: + branch: + 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" + CHANGELOG_SKIP_NO_CHANGELOG: "true" + CHANGELOG_COMPACT: "true" + EXT_VERSION: ${{ env.EXT_VERSION }} + run: | + # Get previous tag's commit + git fetch --tags origin + 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 diff --git a/.github/workflows/vscode-stable-release.yml b/.github/workflows/vscode-stable-release.yml index c71e46553187..9c98995a6c88 100644 --- a/.github/workflows/vscode-stable-release.yml +++ b/.github/workflows/vscode-stable-release.yml @@ -68,6 +68,29 @@ jobs: asset_path: ./vscode/dist/cody.vsix asset_name: cody-vscode-${{ env.EXT_VERSION }}.vsix asset_content_type: application/zip + - 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", + "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 }}" @@ -112,7 +135,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" @@ -131,7 +154,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: | diff --git a/vscode/CHANGELOG.md b/vscode/CHANGELOG.md index 96b671423658..92e8fbf74493 100644 --- a/vscode/CHANGELOG.md +++ b/vscode/CHANGELOG.md @@ -2,6 +2,8 @@ This is a log of all notable changes to Cody for VS Code. +{/* CHANGELOG_START */} + ## [Unreleased] ### Added