Skip to content

Commit 70fb76d

Browse files
committed
Automatically generate helm/changelog PR
1 parent 3fd305c commit 70fb76d

4 files changed

Lines changed: 120 additions & 42 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ jobs:
7070
token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
7171
ref: "master"
7272

73+
- name: Configure git
74+
run: |
75+
git config --global user.name cdrci
76+
git config --global user.email opensource@coder.com
77+
7378
- name: Fetch and reset master
7479
run: |
7580
git remote add upstream https://github.com/coder/code-server-aur.git
7681
git fetch upstream
7782
git reset --hard upstream/master
7883
git push --force
7984
80-
- name: Configure git
81-
run: |
82-
git config --global user.name cdrci
83-
git config --global user.email opensource@coder.com
84-
8585
- name: Validate package
8686
uses: heyhusen/archlinux-package-action@c9f94059ccbebe8710d31d582f33ef4e84fe575c # v3.0.0
8787
with:
@@ -136,3 +136,32 @@ jobs:
136136
out-file-path: "release-packages"
137137

138138
- run: npm run publish:docker
139+
140+
repo:
141+
runs-on: ubuntu-latest
142+
env:
143+
GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
144+
TAG: ${{ inputs.version || github.ref_name }}
145+
needs: docker
146+
147+
steps:
148+
- name: Set version to tag without leading v
149+
run: |
150+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
151+
152+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
153+
154+
- run: ./ci/build/update-repo.sh
155+
156+
- name: Open PR
157+
run: |
158+
git config --global user.name cdrci
159+
git config --global user.email opensource@coder.com
160+
git checkout -b "helm/$VERSION"
161+
git add .
162+
git commit -m "Update to $VERSION"
163+
git push -u origin "$(git branch --show)"
164+
gh pr create \
165+
--repo coder/code-server \
166+
--body-file .cache/checklist \
167+
--title "Update to $VERSION"

ci/build/update-repo.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
3+
set -Eeuo pipefail
4+
5+
function update_helm() {
6+
local current
7+
current=$(yq .version ci/helm-chart/Chart.yaml)
8+
local next
9+
next=$(semver "$current" -i minor)
10+
echo "Bumping version from $current to $next..."
11+
sed -i.bak "s/^version: $current\$/version: $next/" ci/helm-chart/Chart.yaml
12+
13+
echo "Setting app version and image to $version..."
14+
sed -i.bak "s/^appVersion: .\+\$/appVersion: $version/" ci/helm-chart/Chart.yaml
15+
sed -i.bak "s/^ tag: .\+\$/ tag: '$version'/" ci/helm-chart/values.yaml
16+
17+
echo "- [X] Update Helm chart" >> .cache/checklist
18+
}
19+
20+
function update_changelog() {
21+
local date
22+
date=$(printf '%(%Y-%m-%d)T\n' -1)
23+
local link="https://github.com/coder/code-server/releases/tag/v$version"
24+
sed -i.bak "s|## Unreleased|## Unreleased\n\n## [$version]($link) - $date|" CHANGELOG.md
25+
echo "- [X] Update changelog" >> .cache/checklist
26+
}
27+
28+
function main() {
29+
cd "$(dirname "${0}")/../.."
30+
31+
source ./ci/lib.sh
32+
33+
local version=${VERSION:-$(git describe --tags)}
34+
version="${version#v}"
35+
36+
declare -a steps
37+
38+
steps+=(
39+
"Update Helm chart" "update_helm"
40+
"Update changelog" "update_changelog"
41+
)
42+
43+
run-steps "${steps[@]}"
44+
45+
# This step is always manual.
46+
echo "- [ ] https://github.com/coder/code-server-aur/pulls" >> .cache/checklist
47+
}
48+
49+
main "$@"

ci/build/update-vscode.sh

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22

33
set -Eeuo pipefail
44

5-
function quiet() {
6-
"$@" >/dev/null
7-
}
8-
9-
function indent() {
10-
local count=2
11-
local space
12-
space=$(printf "%${count}s")
13-
sed "s/^/$space| /g"
14-
}
15-
165
function unapply_patches() {
176
local -i exit_code=0
187
quiet quilt pop -af || exit_code=$?
@@ -110,31 +99,6 @@ function update_csp() {
11099
fi
111100
}
112101

113-
function run() {
114-
local -i failed=0
115-
rm -f .cache/checklist
116-
while (( $# )) ; do
117-
local name=$1 ; shift
118-
local fn=$1 ; shift
119-
# Only run if an earlier step has not failed.
120-
if [[ $failed == 0 ]] ; then
121-
echo "$name..."
122-
if $fn | indent ; then
123-
echo "- [X] $name" >> .cache/checklist
124-
else
125-
((failed++))
126-
fi
127-
fi
128-
# For all failed steps, write out an empty checkbox.
129-
if [[ $failed != 0 ]] ; then
130-
echo "- [ ] $name" >> .cache/checklist
131-
fi
132-
done
133-
if [[ $failed != 0 ]] ; then
134-
return 1
135-
fi
136-
}
137-
138102
function add_changelog() {
139103
local file=CHANGELOG.md
140104
if grep --quiet "Code $target_vscode_version" "$file" ; then
@@ -181,7 +145,7 @@ function main() {
181145
"Add changelog note" "add_changelog"
182146
)
183147

184-
run "${steps[@]}"
148+
run-steps "${steps[@]}"
185149

186150
# This step is always manual.
187151
echo "- [ ] Verify changelog" >> .cache/checklist

ci/lib.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,42 @@ nodeArch() {
7878
echo "$cpu"
7979
}
8080

81+
run-steps() {
82+
local -i failed=0
83+
rm -f .cache/checklist
84+
while (( $# )) ; do
85+
local name=$1 ; shift
86+
local fn=$1 ; shift
87+
# Only run if an earlier step has not failed.
88+
if [[ $failed == 0 ]] ; then
89+
echo "$name..."
90+
if $fn | indent ; then
91+
echo "- [X] $name" >> .cache/checklist
92+
else
93+
((failed++))
94+
fi
95+
fi
96+
# For all failed steps, write out an empty checkbox.
97+
if [[ $failed != 0 ]] ; then
98+
echo "- [ ] $name" >> .cache/checklist
99+
fi
100+
done
101+
if [[ $failed != 0 ]] ; then
102+
return 1
103+
fi
104+
}
105+
106+
quiet() {
107+
"$@" >/dev/null
108+
}
109+
110+
indent() {
111+
local count=2
112+
local space
113+
space=$(printf "%${count}s")
114+
sed "s/^/$space| /g"
115+
}
116+
81117
# See gulpfile.reh.ts for available targets.
82118
if [[ ! ${VSCODE_TARGET-} ]]; then
83119
VSCODE_TARGET="$(nodeOS)-$(nodeArch)"

0 commit comments

Comments
 (0)