From 72f4b0b8e0fb1ea7f4fce61d79ab47f0af28fb43 Mon Sep 17 00:00:00 2001 From: Richard Davison Date: Wed, 14 Sep 2022 17:14:29 -0400 Subject: [PATCH 1/7] Scripts: Push to github in opam-release.sh --- scripts/opam-release.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/opam-release.sh b/scripts/opam-release.sh index b75fe88cc232..917d904ece10 100755 --- a/scripts/opam-release.sh +++ b/scripts/opam-release.sh @@ -21,6 +21,7 @@ The script downloads it to compute sha256 and sha512 checksums for you." version="${1:-}" url="${2:-}" opam_dir="${3:-opam-repository}" +opam_repository_fork="git@github.com:tezos/opam-repository" if [ -z "$version" ] ; then echo "$usage" @@ -73,3 +74,11 @@ git checkout -b "$branch" git add packages git commit -am "Octez $version packages" log "A branch named $branch has been created in $opam_dir." +git remote add github "$opam_repository_fork" +log "Pushing $branch to $opam_repository_fork" +git push -u github "$branch" +log "Updating master branch" +git checkout master +git pull +log "Pushing master branch to $opam_repository_fork" +git push -u github master \ No newline at end of file -- GitLab From 86e2efc984c57e7b891852005be0269648737a9f Mon Sep 17 00:00:00 2001 From: Richard Davison Date: Wed, 14 Sep 2022 17:15:58 -0400 Subject: [PATCH 2/7] Scripts: Precompute an opam_release_tag in release.sh --- scripts/ci/release.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/ci/release.sh b/scripts/ci/release.sh index 8a9f4f9c73f1..1b33f2d8cc7e 100755 --- a/scripts/ci/release.sh +++ b/scripts/ci/release.sh @@ -36,10 +36,12 @@ then # Yes, release name: X.Y~rcZ # shellcheck disable=SC2034 gitlab_release_name="${gitlab_release_major_version}.${gitlab_release_minor_version}~rc${gitlab_release_rc_version}" + opam_release_tag="${gitlab_release_major_version}.${gitlab_release_minor_version}~rc${gitlab_release_rc_version}" else # No, release name: Release X.Y # shellcheck disable=SC2034 gitlab_release_name="Release ${gitlab_release_major_version}.${gitlab_release_minor_version}" + opam_release_tag="${gitlab_release_major_version}.${gitlab_release_minor_version}" fi ### Compute GitLab generic package names -- GitLab From 9123c5385e0eaa8c85cfc5a2da8b10efa6fdae8c Mon Sep 17 00:00:00 2001 From: Richard Davison Date: Wed, 14 Sep 2022 17:15:01 -0400 Subject: [PATCH 3/7] CI: Create wrapper script to call opam-release.sh --- scripts/ci/opam-release.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/ci/opam-release.sh diff --git a/scripts/ci/opam-release.sh b/scripts/ci/opam-release.sh new file mode 100644 index 000000000000..59713a06d4b4 --- /dev/null +++ b/scripts/ci/opam-release.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +ci_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" +script_dir="$(dirname "$ci_dir")" + +# shellcheck source=./scripts/ci/release.sh +. "$ci_dir/release.sh" + +# set up ssh credentials to access github +mkdir -p "$HOME/.ssh" +cp "$TEZOS_GITHUB_OPAM_REPOSITORY_MACHINE_USER_PRIVATE_SSH_KEY" "$HOME/.ssh/id_rsa" +cat "$GITHUB_SSH_HOST_KEYS" >> "$HOME/.ssh/known_hosts" +chmod 600 "$HOME/known_hosts" +chmod 600 "$HOME/id_rsa" +chmod 700 "$HOME/.ssh" + +# call opam-release.sh with the correct arguments +"$script_dir/opam-release.sh" \ + "$opam_release_tag" \ + "https://gitlab.com/tezos/tezos/-/archive/$CI_COMMIT_TAG/$gitlab_package_name.tar.gz" \ No newline at end of file -- GitLab From ffd146088370a2e814c3bad22944a75743c05081 Mon Sep 17 00:00:00 2001 From: Richard Davison Date: Wed, 14 Sep 2022 17:16:15 -0400 Subject: [PATCH 4/7] CI: Add opam:release job --- .gitlab/ci/publish_release.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.gitlab/ci/publish_release.yml b/.gitlab/ci/publish_release.yml index 921f686b4fcd..803d12920f9a 100644 --- a/.gitlab/ci/publish_release.yml +++ b/.gitlab/ci/publish_release.yml @@ -14,6 +14,20 @@ gitlab:release: script: - make -C ${CI_PROJECT_DIR}/.gitlab/ci gitlab-release +opam:release: + extends: + - .default_settings_template + - .image_template__runtime_build_test_dependencies_template + - .rules_template__release_tag + stage: publish_release + # Publish jobs are uninterruptible to avoid publishing partial results. + interruptible: false + dependencies: + - gitlab:release + script: + # create opam release and push to github (also pushes latest master branch) + - ./scripts/ci/opam-release.sh + # Note: here we rely on $IMAGE_ARCH_PREFIX to be empty. # Otherwise, $DOCKER_IMAGE_TAG would contain $IMAGE_ARCH_PREFIX too. # $IMAGE_ARCH_PREFIX is only used when building Docker images, -- GitLab From 18f47a773085495978e19e6a820b2b3bac0a36b7 Mon Sep 17 00:00:00 2001 From: Richard Davison Date: Wed, 14 Sep 2022 17:46:43 -0400 Subject: [PATCH 5/7] CI: Implement Makefile target for opam-release --- .gitlab/ci/Makefile | 7 ++++++- .gitlab/ci/publish_release.yml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/Makefile b/.gitlab/ci/Makefile index 65b26df795d6..131215649ec8 100644 --- a/.gitlab/ci/Makefile +++ b/.gitlab/ci/Makefile @@ -150,6 +150,11 @@ doc-publish: cd ${CI_PROJECT_DIR} && \ ./scripts/ci/doc_publish.sh +.PHONY: opam-release +opam-release: + cd ${CI_PROJECT_DIR} ; \ + ./scripts/ci/opam-release.sh + .PHONY: gitlab-release gitlab-release: cd ${CI_PROJECT_DIR} && \ @@ -161,4 +166,4 @@ gitlab-take-ownership: ifdef CI_PROJECT_DIR # FIXME: https://gitlab.com/tezos/tezos/-/issues/2865 sudo chown -R $(shell id -u):$(shell id -g) ${CI_PROJECT_DIR} -endif +endif \ No newline at end of file diff --git a/.gitlab/ci/publish_release.yml b/.gitlab/ci/publish_release.yml index 803d12920f9a..efac28d458d4 100644 --- a/.gitlab/ci/publish_release.yml +++ b/.gitlab/ci/publish_release.yml @@ -26,7 +26,7 @@ opam:release: - gitlab:release script: # create opam release and push to github (also pushes latest master branch) - - ./scripts/ci/opam-release.sh + - make -C ${CI_PROJECT_DIR}/.gitlab/ci opam-release # Note: here we rely on $IMAGE_ARCH_PREFIX to be empty. # Otherwise, $DOCKER_IMAGE_TAG would contain $IMAGE_ARCH_PREFIX too. -- GitLab From 281a4575b5f8c5f404901f818a58fd746142ad53 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Thu, 15 Sep 2022 17:17:34 +0200 Subject: [PATCH 6/7] CI: chmod +x opam-release.sh --- scripts/ci/opam-release.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/ci/opam-release.sh diff --git a/scripts/ci/opam-release.sh b/scripts/ci/opam-release.sh old mode 100644 new mode 100755 -- GitLab From 628c1a4187dc7e111c3df173f1ee62f232c28c99 Mon Sep 17 00:00:00 2001 From: Romain Bardou Date: Thu, 15 Sep 2022 17:29:11 +0200 Subject: [PATCH 7/7] CI: improve opam-release.sh --- scripts/ci/opam-release.sh | 29 ++++++++++++++++++++++++++--- scripts/opam-release.sh | 10 +--------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/scripts/ci/opam-release.sh b/scripts/ci/opam-release.sh index 59713a06d4b4..de2ea7b6736e 100755 --- a/scripts/ci/opam-release.sh +++ b/scripts/ci/opam-release.sh @@ -5,6 +5,13 @@ set -e ci_dir="$(cd "$(dirname "$0")" && echo "$(pwd -P)/")" script_dir="$(dirname "$ci_dir")" +opam_repository_fork="git@github.com:tezos/opam-repository" +opam_dir="opam-repository" + +log () { + echo '\e[1m'"$1"'\e[0m' +} + # shellcheck source=./scripts/ci/release.sh . "$ci_dir/release.sh" @@ -12,11 +19,27 @@ script_dir="$(dirname "$ci_dir")" mkdir -p "$HOME/.ssh" cp "$TEZOS_GITHUB_OPAM_REPOSITORY_MACHINE_USER_PRIVATE_SSH_KEY" "$HOME/.ssh/id_rsa" cat "$GITHUB_SSH_HOST_KEYS" >> "$HOME/.ssh/known_hosts" -chmod 600 "$HOME/known_hosts" -chmod 600 "$HOME/id_rsa" +chmod 600 "$HOME/.ssh/known_hosts" +chmod 600 "$HOME/.ssh/id_rsa" chmod 700 "$HOME/.ssh" +log "Done setting up credentials." # call opam-release.sh with the correct arguments "$script_dir/opam-release.sh" \ "$opam_release_tag" \ - "https://gitlab.com/tezos/tezos/-/archive/$CI_COMMIT_TAG/$gitlab_package_name.tar.gz" \ No newline at end of file + "https://gitlab.com/tezos/tezos/-/archive/$CI_COMMIT_TAG/$gitlab_package_name.tar.gz" \ + "$opam_dir" + +# Matches the corresponding variable in /scripts/opam-release.sh. +branch_name="octez-$opam_release_tag" + +log "While we're here, update master on the fork..." +cd "$opam_dir" +git remote add github "$opam_repository_fork" +git push github master:master + +log "Pushing $branch_name to $opam_repository_fork..." +git push --force-with-lease github "${branch_name}:${branch_name}" + +log "Create the pull request at:" +log "https://github.com/ocaml/opam-repository/compare/master...tezos:opam-repository:${branch_name}" diff --git a/scripts/opam-release.sh b/scripts/opam-release.sh index 917d904ece10..15b9ca981f73 100755 --- a/scripts/opam-release.sh +++ b/scripts/opam-release.sh @@ -21,7 +21,6 @@ The script downloads it to compute sha256 and sha512 checksums for you." version="${1:-}" url="${2:-}" opam_dir="${3:-opam-repository}" -opam_repository_fork="git@github.com:tezos/opam-repository" if [ -z "$version" ] ; then echo "$usage" @@ -73,12 +72,5 @@ branch="octez-""$(echo "$version" | tr '~' -)" git checkout -b "$branch" git add packages git commit -am "Octez $version packages" + log "A branch named $branch has been created in $opam_dir." -git remote add github "$opam_repository_fork" -log "Pushing $branch to $opam_repository_fork" -git push -u github "$branch" -log "Updating master branch" -git checkout master -git pull -log "Pushing master branch to $opam_repository_fork" -git push -u github master \ No newline at end of file -- GitLab