vscode-generate-changelog #42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: vscode-generate-changelog | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'The version to be released, for example: 1.60.0' | |
required: true | |
type: string | |
release_tag: | |
description: | | |
'Optional: Generate changelog since a specific release. ex - vscode-v1.58' | |
If no release_tag is specified, the changelog will be generated from the latest release tag. | |
required: false | |
type: string | |
jobs: | |
changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.inputs.branch }} | |
- name: Configure git | |
run: | | |
git config --global user.name 'sourcegraph-bot' | |
git config --global user.email '[email protected]' | |
git fetch --tags origin | |
- name: Download changelog | |
env: | |
GH_TOKEN: ${{ secrets.DEVX_SERVICE_GH_TOKEN }} | |
run: | | |
# 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 | |
- name: Generate changelog | |
env: | |
GH_TOKEN: ${{ secrets.DEVX_SERVICE_GH_TOKEN }} | |
GH_REPO: "sourcegraph/cody" | |
CHANGELOG_SKIP_NO_CHANGELOG: "true" | |
CHANGELOG_COMPACT: "true" | |
VERSION: ${{ github.event.inputs.version }} | |
RELEASE_TAG: ${{ github.event.inputs.release_tag }} | |
run: | | |
set +x | |
export CHANGELOG_SKIP_NO_CHANGELOG="false" | |
export CHANGELOG_COMPACT="false" | |
# Use provided release tag if available, otherwise get previous tag | |
if [ -n "$RELEASE_TAG" ]; then | |
export RELEASE_LATEST_RELEASE=$(git rev-parse $RELEASE_TAG) | |
else | |
# 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) | |
fi | |
# Get current release commit | |
export RELEASE_LATEST_COMMIT=$(git rev-parse HEAD) | |
echo "Latest Commit: $RELEASE_LATEST_COMMIT" | |
echo "Latest Release: $RELEASE_LATEST_RELEASE" | |
echo $VERSION | |
./changelog update-as-pr \ | |
--github.repo=$GH_REPO \ | |
--output.repo.base="main" \ | |
--output.repo=$GH_REPO \ | |
--output.pr.branch="release/vscode-v%s" \ | |
--output.pr.title="Changelog for v%s" \ | |
--output.pr.body="Automated release and changelog for VS code Cody v%s" \ | |
--output.changelog="vscode/CHANGELOG.md" \ | |
--output.changelog.marker='<!--- {/_ CHANGELOG_START _/} -->' \ | |
--releaseregistry.version=${VERSION} | |
- name: Update version | |
env: | |
VERSION: ${{ github.event.inputs.version }} | |
run: | | |
set +x | |
# git checkout -b version-update/$VERSION | |
sed -i 's/"version": "[0-9]\+\.[0-9]\+\.[0-9]\+"/"version": "'$VERSION'"/' vscode/package.json | |
# This will get tagged along with the changelog PR | |
git add vscode/package.json | |
git pull | |
git checkout release/vscode-v$VERSION | |
git commit -m "Update version to $VERSION" | |
git push |