Skip to content

Automate draft release #1623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ Any file and directory added into this tree should be documented here.

## Publishing a release

Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub) installed.

1. Update the version of code-server in `package.json` and push a commit
1. CI will run and generate the `npm-package` and `release-packages` artifacts on the GH actions workflow
1. Create a new draft release and attach all files in `release-packages`
1. Run some basic sanity tests on one of the released packages
1. Summarize the major changes in the release notes and link to the relevant issues.
1. Make sure to mention the VS Code version in the release notes
1. GitHub actions will generate the `npm-package` and `release-packages` artifacts
1. Run `yarn release:github-draft` to create a GitHub draft release from the template with
the updated version.
1. Summarize the major changes in the release notes and link to the relevant issues.
1. Wait for the artifacts in step 2 to build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we number these incrementally instead of just with 1? Normally I don't pay much attention but since we called out step 2 I was trying to count up in my head and got lost a couple times lol especially since Github is rendering a gap after 2 for some reason and I kept thinking it was a separate paragraph. I always read the readmes raw so maybe that's just a me problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually in markdown you don't want to number them to avoid forgetting updates since when it renders it's immediately there but I agree it is nice when looking at the raw markdown.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I see no gap after 2, that's weird.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It must have something to do with the specific screen size I have my browser at. My editor automatically updates the numbers so I was hoping there was something similar for yours.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goland aint as cool as emacs :(

1. Run `yarn release:github-assets` to download the artifacts and then upload them to the draft release
1. Run some basic sanity tests on one of the released packages
1. Publish the release
1. CI will automatically grab the artifacts and then
1. Publish the NPM package
Expand Down Expand Up @@ -45,7 +49,7 @@ This directory contains scripts used for the development of code-server.

## build

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

- [./lib.sh](./lib.sh)
Expand Down Expand Up @@ -74,6 +78,12 @@ You can disable minification by setting `MINIFY=`.
- Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm
- [./build/code-server-nfpm.sh](./build/code-server-nfpm.sh)
- Entrypoint script for code-server for .deb and .rpm
- [./build/release-github-draft.sh](./build/release-github-draft.sh) (`yarn release:github-draft`)
- Uses [hub](https://github.com/github/hub) to create a draft release with a template description
- [./build/release-github-assets.sh](./build/release-github-assets.sh) (`yarn release:github-assets`)
- Downloads the release-package artifacts for the current commit from CI
- Uses [hub](https://github.com/github/hub) to upload the artifacts to the release
specified in `package.json`

## release-container

Expand Down
21 changes: 21 additions & 0 deletions ci/build/release-github-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail

# Downloads the release artifacts from CI for the current
# commit and then uploads them to the release with the version
# in package.json.
# You will need $GITHUB_TOKEN set.

main() {
cd "$(dirname "$0")/../.."
source ./ci/lib.sh

download_artifact release-packages ./release-packages
local assets=(./release-packages/*)
for i in "${!assets[@]}"; do
assets[$i]="--attach=${assets[$i]}"
done
EDITOR=true hub release edit --draft "${assets[@]}" "v$(pkg_json_version)"
}

main "$@"
21 changes: 21 additions & 0 deletions ci/build/release-github-draft.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail

# Creates a draft release with the template for the version in package.json

main() {
cd "$(dirname "$0")/../.."
source ./ci/lib.sh

hub release create \
--file - \
--draft "${assets[@]}" "v$(pkg_json_version)" << EOF
v$(pkg_json_version)

VS Code v$(vscode_version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice 👍


- Summarize changes here with references to issues
EOF
}

main "$@"
2 changes: 1 addition & 1 deletion ci/dev/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ main() {
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js")
stylelint $(git ls-files "*.css")
tsc --noEmit
shellcheck -e SC2046,SC2164 $(git ls-files "*.sh")
shellcheck -e SC2046,SC2164,SC2154 $(git ls-files "*.sh")
}

main "$@"
35 changes: 35 additions & 0 deletions ci/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ pkg_json_version() {
jq -r .version package.json
}

vscode_version() {
jq -r .version lib/vscode/package.json
}

os() {
local os
os=$(uname | tr '[:upper:]' '[:lower:]')
Expand Down Expand Up @@ -41,3 +45,34 @@ arch() {
;;
esac
}

curl() {
command curl -H "Authorization: token $GITHUB_TOKEN" "$@"
}

# Grabs the most recent ci.yaml github workflow run that was successful and triggered from the same commit being pushd.
# This will contain the artifacts we want.
# https://developer.github.com/v3/actions/workflow-runs/#list-workflow-runs
get_artifacts_url() {
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
}

# Grabs the artifact's download url.
# https://developer.github.com/v3/actions/artifacts/#list-workflow-run-artifacts
get_artifact_url() {
local artifact_name="$1"
curl -sSL "$(get_artifacts_url)" | jq -r ".artifacts[] | select(.name == \"$artifact_name\") | .archive_download_url" | head -n 1
}

# Uses the above two functions to download a artifact into a directory.
download_artifact() {
local artifact_name="$1"
local dst="$2"

local tmp_file
tmp_file="$(mktemp)"

curl -sSL "$(get_artifact_url "$artifact_name")" > "$tmp_file"
unzip -o "$tmp_file" -d "$dst"
rm "$tmp_file"
}
29 changes: 0 additions & 29 deletions ci/steps/lib.sh

This file was deleted.

2 changes: 1 addition & 1 deletion ci/steps/publish-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail

main() {
cd "$(dirname "$0")/../.."
source ./ci/steps/lib.sh
source ./ci/lib.sh

if [[ ${CI-} ]]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
Expand Down
2 changes: 1 addition & 1 deletion ci/steps/publish-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail

main() {
cd "$(dirname "$0")/../.."
source ./ci/steps/lib.sh
source ./ci/lib.sh

if [[ ${CI-} ]]; then
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"build:vscode": "./ci/build/build-vscode.sh",
"release": "./ci/build/build-release.sh",
"release:static": "./ci/build/build-static-release.sh",
"release:github-draft": "./ci/build/release-github-draft.sh",
"release:github-assets": "./ci/build/release-github-assets.sh",
"test:static-release": "./ci/build/test-static-release.sh",
"package": "./ci/build/build-packages.sh",
"_____": "",
Expand Down