This repository was archived by the owner on Aug 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 488
121 lines (111 loc) · 4.53 KB
/
Copy pathgenerate-changelog.yml
File metadata and controls
121 lines (111 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: vscode-generate-changelog
on:
workflow_dispatch:
inputs:
editor:
description: 'Select editor to create changelog for'
required: true
type: choice
default: 'VS Code'
options:
- VS Code
version:
description: |
The version to be released, this will be used as the header of the changelog
Ex - 1.60.0
required: true
type: string
bump_version:
description: 'Optional: Bump VS Code version - If checked, the VS Code version will be bumped to the specified version from above.'
required: false
type: boolean
default: false
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
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
- name: Configure git
run: |
git config --global user.name 'sourcegraph-bot'
git config --global user.email 'bot@sourcegraph.com'
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: "false"
CHANGELOG_COMPACT: "false"
VERSION: ${{ github.event.inputs.version }}
RELEASE_TAG: ${{ github.event.inputs.release_tag }}
EDITOR: ${{ github.event.inputs.editor }}
run: |
set +x
# 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 based on editor selection
if [ "$EDITOR" = "VS Code" ]; then
PREV_TAG=$(git tag --sort=-v:refname | grep '^vscode-v' | head -n 2 | tail -n 1)
else
# not used at the moment as we don't support JetBrains only changelog
PREV_TAG=$(git tag --sort=-v:refname | grep '^jb-v' | head -n 2 | tail -n 1)
fi
export RELEASE_LATEST_RELEASE=$(git rev-parse $PREV_TAG)
fi
# Set editor-specific variables
if [ "$EDITOR" = "VS Code" ]; then
CHANGELOG_PATH="vscode/CHANGELOG.md"
PR_BRANCH="release/vscode-v%s"
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"
# see https://github.com/sourcegraph/devx-service/tree/main/cmd/changelog for binary details
./changelog update-as-pr \
--github.repo=$GH_REPO \
--github.fetch-strategy="between-commit" \
--output.repo.base="main" \
--output.repo=$GH_REPO \
--output.pr.branch="$PR_BRANCH" \
--output.pr.title="Changelog for %s" \
--output.pr.body="Automated release and changelog for Cody VS Code %s
## Test plan
N/A - changelog update" \
--output.changelog="$CHANGELOG_PATH" \
--output.changelog.marker='<!--- {/_ CHANGELOG_START _/} -->' \
--releaseregistry.version=${VERSION}
- name: Update version
if: ${{ github.event.inputs.bump_version == 'true' }}
env:
VERSION: ${{ github.event.inputs.version }}
run: |
set +x
git pull
git checkout release/vscode-v$VERSION
sed -i 's/"version": "[0-9]\+\.[0-9]\+\.[0-9]\+"/"version": "'$VERSION'"/' vscode/package.json
git add vscode/package.json
git commit -m "Update version to $VERSION"
git push