Skip to content

Fix Docker push #3796

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 5 commits into from
Jul 16, 2021
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
2 changes: 1 addition & 1 deletion ci/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ get_artifacts_url() {
artifacts_url=$(gh api "$workflow_runs_url" | jq -r ".workflow_runs[] | select(.head_branch == \"$version_branch\") | .artifacts_url" | head -n 1)
if [[ -z "$artifacts_url" ]]; then
echo >&2 "ERROR: artifacts_url came back empty"
echo >&2 "We looked for a successful run triggered by a pull_request with for code-server version: $code_server_version and a branch named $version_branch"
echo >&2 "We looked for a successful run triggered by a pull_request with for code-server version: $VERSION and a branch named $version_branch"
echo >&2 "URL used for gh API call: $workflow_runs_url"
exit 1
fi
Expand Down
14 changes: 11 additions & 3 deletions ci/steps/brew-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ main() {
echo "Adding Homebrew/homebrew-core as $(upstream)"
git remote add upstream https://github.com/Homebrew/homebrew-core.git

echo "Fetching upstream commits..."
echo "Fetching upstream Homebrew/hombrew-core commits"
git fetch upstream

echo "Merging in latest changes"
echo "Merging in latest Homebrew/homebrew-core changes"
git merge upstream/master

echo "Pushing changes to cdrci/homebrew-core fork on GitHub"
Expand All @@ -37,7 +37,15 @@ main() {

# Find the docs for bump-formula-pr here
# https://github.com/Homebrew/brew/blob/master/Library/Homebrew/dev-cmd/bump-formula-pr.rb#L18
brew bump-formula-pr --force --version="${VERSION}" code-server --no-browse --no-audit
local output
if ! output=$(brew bump-formula-pr --version="${VERSION}" code-server --no-browse --no-audit 2>&1); then
if [[ $output == *"Duplicate PRs should not be opened"* ]]; then
echo "$VERSION is already submitted"
else
echo "$output"
exit 1
fi
fi

# Clean up and remove homebrew-core
cd ..
Expand Down
8 changes: 8 additions & 0 deletions ci/steps/publish-npm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ main() {
cd "$(dirname "$0")/../.."
source ./ci/lib.sh

# npm view won't exit with non-zero so we have to check the output.
local hasVersion
hasVersion=$(npm view "code-server@$VERSION" version)
if [[ $hasVersion == "$VERSION" ]]; then
echo "$VERSION is already published"
return
fi

if [[ ${CI-} ]]; then
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
fi
Expand Down
61 changes: 39 additions & 22 deletions ci/steps/push-docker-manifest.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,54 @@
#!/usr/bin/env bash
set -euo pipefail

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

download_artifact release-images ./release-images
if [[ ${CI-} ]]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# See if this version already exists on Docker Hub.
function version_exists() {
local output
output=$(curl --silent "https://index.docker.io/v1/repositories/codercom/code-server/tags/$VERSION")
if [[ $output == "Tag not found" ]]; then
return 1
else
return 0
fi
}

# Import and push the Docker image for the provided arch.
push() {
local arch=$1
local tag="codercom/code-server-$arch:$VERSION"

for img in ./release-images/*; do
docker load -i "$img"
done
docker import "./release-images/code-server-$arch-$VERSION.tar" "$tag"

# We have to ensure the amd64 and arm64 images exist on the remote registry
# in order to build the manifest.
# We don't put the arch in the tag to avoid polluting the main repository.
# These other repositories are private so they don't pollute our organization namespace.
docker push "codercom/code-server-amd64:$VERSION"
docker push "codercom/code-server-arm64:$VERSION"
# We have to ensure the images exists on the remote registry in order to build
# the manifest. We don't put the arch in the tag to avoid polluting the main
# repository. These other repositories are private so they don't pollute our
# organization namespace.
docker push "$tag"

export DOCKER_CLI_EXPERIMENTAL=enabled

docker manifest create "codercom/code-server:$VERSION" \
"codercom/code-server-amd64:$VERSION" \
"codercom/code-server-arm64:$VERSION"
"codercom/code-server-$arch:$VERSION" \
"codercom/code-server-$arch:$VERSION"
docker manifest push --purge "codercom/code-server:$VERSION"
}

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

if version_exists; then
echo "$VERSION is already pushed"
return
fi

download_artifact release-images ./release-images
if [[ ${CI-} ]]; then
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
fi

docker manifest create "codercom/code-server:latest" \
"codercom/code-server-amd64:$VERSION" \
"codercom/code-server-arm64:$VERSION"
docker manifest push --purge "codercom/code-server:latest"
push "amd64"
push "arm64"
}

main "$@"