Skip to content

Commit c3de376

Browse files
committed
Automate draft release
1 parent b706e85 commit c3de376

File tree

7 files changed

+79
-36
lines changed

7 files changed

+79
-36
lines changed

ci/README.md

+12-5
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ Any file and directory added into this tree should be documented here.
1010

1111
1. Update the version of code-server in `package.json` and push a commit
1212
1. CI will run and generate the `npm-package` and `release-packages` artifacts on the GH actions workflow
13-
1. Create a new draft release and attach all files in `release-packages`
14-
1. Run some basic sanity tests on one of the released packages
15-
1. Summarize the major changes in the release notes and link to the relevant issues.
16-
1. Make sure to mention the VS Code version in the release notes
13+
1. Wait for this to complete
14+
1. Ensure `$GITHUB_TOKEN` is set
15+
1. Run `yarn release:github-draft` to download the artifacts into `./release-packages` and
16+
open your `$EDITOR` with the release notes template
17+
1. Summarize the major changes in the release notes and link to the relevant issues.
18+
1. Exit your `$EDITOR` and a draft release will be created on github
19+
1. Run some basic sanity tests on one of the released packages
1720
1. Publish the release
1821
1. CI will automatically grab the artifacts and then
1922
1. Publish the NPM package
@@ -45,7 +48,7 @@ This directory contains scripts used for the development of code-server.
4548

4649
## build
4750

48-
This directory contains the scripts used to build code-server.
51+
This directory contains the scripts used to build and release code-server.
4952
You can disable minification by setting `MINIFY=`.
5053

5154
- [./lib.sh](./lib.sh)
@@ -74,6 +77,10 @@ You can disable minification by setting `MINIFY=`.
7477
- Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm
7578
- [./build/code-server-nfpm.sh](./build/code-server-nfpm.sh)
7679
- Entrypoint script for code-server for .deb and .rpm
80+
- [./build/release-github-draft.sh](./build/release-github-draft.sh) (`yarn release:github-draft`)
81+
- Downloads the release-package artifact for the current commit from CI
82+
- Uses [hub](https://github.com/github/hub) to create a draft release with the artifacts and
83+
opens your `$EDITOR` to edit with a default template.
7784

7885
## release-container
7986

ci/build/release-github-draft.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# This script downloads the release artifacts from CI for the current
5+
# commit and then uses hub to create a draft release with them attached
6+
# for the current version against the current commit.
7+
# You will need $GITHUB_TOKEN set.
8+
9+
main() {
10+
cd "$(dirname "$0")/../.."
11+
source ./ci/lib.sh
12+
13+
download_artifact release-packages ./release-packages
14+
local assets=(./release-packages/*)
15+
for i in "${!assets[@]}"; do
16+
assets[$i]="--attach=${assets[$i]}"
17+
done
18+
hub release create \
19+
--edit --file - \
20+
--draft "${assets[@]}" "v$(pkg_json_version)" << EOF
21+
v$(pkg_json_version)
22+
23+
VS Code v$(vscode_version)
24+
25+
- Summarize changes here with references to issues
26+
EOF
27+
}
28+
29+
main "$@"

ci/lib.sh

+35
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ pkg_json_version() {
1212
jq -r .version package.json
1313
}
1414

15+
vscode_version() {
16+
jq -r .version lib/vscode/package.json
17+
}
18+
1519
os() {
1620
local os
1721
os=$(uname | tr '[:upper:]' '[:lower:]')
@@ -41,3 +45,34 @@ arch() {
4145
;;
4246
esac
4347
}
48+
49+
curl() {
50+
command curl -H "Authorization: token $GITHUB_TOKEN" "$@"
51+
}
52+
53+
# Grabs the most recent ci.yaml github workflow run that was successful and triggered from the same commit being pushd.
54+
# This will contain the artifacts we want.
55+
# https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
56+
get_artifacts_url() {
57+
curl -sSL 'https://api.github.com/repos/cdr/code-server/actions/workflows/ci.yaml/runs?status=success&event=push' | jq -r ".workflow_runs[] | select(.head_sha == \"$(git rev-parse HEAD)\") | .artifacts_url" | head -n 1
58+
}
59+
60+
# Grabs the artifact's download url.
61+
# https://developer.github.com/v3/actions/artifacts/#list-workflow-run-artifacts
62+
get_artifact_url() {
63+
local artifact_name="$1"
64+
curl -sSL "$(get_artifacts_url)" | jq -r ".artifacts[] | select(.name == \"$artifact_name\") | .archive_download_url" | head -n 1
65+
}
66+
67+
# Uses the above two functions to download a artifact into a directory.
68+
download_artifact() {
69+
local artifact_name="$1"
70+
local dst="$2"
71+
72+
local tmp_file
73+
tmp_file="$(mktemp)"
74+
75+
curl -sSL "$(get_artifact_url "$artifact_name")" > "$tmp_file"
76+
unzip -o "$tmp_file" -d "$dst"
77+
rm "$tmp_file"
78+
}

ci/steps/lib.sh

-29
This file was deleted.

ci/steps/publish-docker.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -euo pipefail
33

44
main() {
55
cd "$(dirname "$0")/../.."
6-
source ./ci/steps/lib.sh
6+
source ./ci/lib.sh
77

88
if [[ ${CI-} ]]; then
99
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

ci/steps/publish-npm.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -euo pipefail
33

44
main() {
55
cd "$(dirname "$0")/../.."
6-
source ./ci/steps/lib.sh
6+
source ./ci/lib.sh
77

88
if [[ ${CI-} ]]; then
99
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"build:vscode": "./ci/build/build-vscode.sh",
1818
"release": "./ci/build/build-release.sh",
1919
"release:static": "./ci/build/build-static-release.sh",
20+
"release:github-draft": "./ci/build/release-github-draft.sh",
2021
"test:static-release": "./ci/build/test-static-release.sh",
2122
"package": "./ci/build/build-packages.sh",
2223
"_____": "",

0 commit comments

Comments
 (0)