diff --git a/.gitlab/ci/jobs/publish/gitlab:release.yml b/.gitlab/ci/jobs/publish/gitlab:release.yml index 22a33598e2c49449cdbf24cde2ed0d80949d4a11..cf9487b529254b8308ffff26ba70be75cd0b8932 100644 --- a/.gitlab/ci/jobs/publish/gitlab:release.yml +++ b/.gitlab/ci/jobs/publish/gitlab:release.yml @@ -12,4 +12,7 @@ gitlab:release: - oc.build:dpkg:amd64 - oc.build:rpm:amd64 script: + # Set .gitattributes to restrict the tarball create + # by gitlab-release.sh to Octez. + - ./scripts/ci/restrict_export_to_octez_source.sh - ./scripts/ci/gitlab-release.sh diff --git a/Makefile b/Makefile index b7f910de1ded81da4f20ea748367a71692ae6d36..fa0dc74074323c73ef93c5e0a285a5c6bb938820 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,9 @@ DEV_EXECUTABLES := $(shell cat script-inputs/dev-executables) ALL_EXECUTABLES := $(RELEASED_EXECUTABLES) $(EXPERIMENTAL_EXECUTABLES) $(DEV_EXECUTABLES) +#Define octez only executables by excluding the EVM-node. +OCTEZ_ONLY_EXECUTABLES := $(filter-out octez-evm-node,${ALL_EXECUTABLES}) + # Set of Dune targets to build, in addition to OCTEZ_EXECUTABLES, in # the `build` target's Dune invocation. This is used in the CI to # build the TPS evaluation tool, Octogram and the Tezt test suite in the @@ -103,6 +106,10 @@ all: release: @$(MAKE) build PROFILE=release OCTEZ_EXECUTABLES?="$(RELEASED_EXECUTABLES)" +.PHONY: octez +octez: + @$(MAKE) build PROFILE=release OCTEZ_EXECUTABLES?="$(OCTEZ_ONLY_EXECUTABLES)" + .PHONY: experimental-release experimental-release: @$(MAKE) build PROFILE=release OCTEZ_EXECUTABLES?="$(RELEASED_EXECUTABLES) $(EXPERIMENTAL_EXECUTABLES)" diff --git a/script-inputs/octez-source-content b/script-inputs/octez-source-content new file mode 100644 index 0000000000000000000000000000000000000000..cfa5c45661c4cd455a4dc3131c863334cdf1bb89 --- /dev/null +++ b/script-inputs/octez-source-content @@ -0,0 +1,12 @@ +src +tezt +Makefile +dune +dune-project +dune-workspace +CHANGES.rst +LICENSES +opam +script-inputs +scripts +irmin diff --git a/scripts/ci/create_gitlab_package.sh b/scripts/ci/create_gitlab_package.sh index 194106429fe4db77bb1469dc1d1e072edcce942a..1a2656e700ac23950f5e79102e5800f39b2deeb4 100755 --- a/scripts/ci/create_gitlab_package.sh +++ b/scripts/ci/create_gitlab_package.sh @@ -13,9 +13,10 @@ set -eu # https://docs.gitlab.com/ee/user/packages/generic_packages/index.html#download-package-file # :gitlab_api_url/projects/:id/packages/generic/:package_name/:package_version/:file_name -gitlab_octez_package_url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${gitlab_octez_package_name}/${gitlab_package_version}" +gitlab_octez_package_url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${gitlab_octez_binaries_package_name}/${gitlab_package_version}" gitlab_octez_deb_package_url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${gitlab_octez_deb_package_name}/${gitlab_package_version}" gitlab_octez_rpm_package_url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${gitlab_octez_rpm_package_name}/${gitlab_package_version}" +gitlab_octez_source_package_url="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${gitlab_octez_source_package_name}/${gitlab_package_version}" gitlab_upload() { local_path="${1}" @@ -65,7 +66,7 @@ for architecture in ${architectures}; do cd octez-binaries/ tar -czf "octez-${architecture}.tar.gz" "octez-${architecture}/" - gitlab_upload "octez-${architecture}.tar.gz" "${gitlab_octez_package_name}-linux-${architecture}.tar.gz" + gitlab_upload "octez-${architecture}.tar.gz" "${gitlab_octez_binaries_package_name}-linux-${architecture}.tar.gz" cd .. done @@ -88,27 +89,28 @@ done # => create and upload manually echo 'Upload tarball of source code and its checksums' -source_tarball="${gitlab_octez_package_name}.tar.bz2" +source_tarball="${gitlab_octez_source_package_name}.tar.bz2" -# We are using the export-subst feature of git onfigured in .gitattributes, requires git version >= 2.35 +# We are using the export-subst feature of git configured in .gitattributes, requires git version >= 2.35 # https://git-scm.com/docs/git-archive # https://git-scm.com/docs/gitattributes#_creating_an_archive git --version # Verify the placeholder %(describe:tags) is available git describe --tags -# Create tarball -git archive "${CI_COMMIT_TAG}" --format=tar | bzip2 > "${source_tarball}" +# Pass '--worktree-attributes' to ensure that ignores written by restrict_export_to_octez_source.sh +# are respected. +git archive "${CI_COMMIT_TAG}" --format=tar --worktree-attributes --prefix "${gitlab_octez_source_package_name}/" | bzip2 > "${source_tarball}" # Check tarball is valid tar -tjf "${source_tarball}" > /dev/null # Verify git expanded placeholders in archive -tar -Oxf "${source_tarball}" src/lib_version/exe/get_git_info.ml | grep "let raw_current_version = \"${CI_COMMIT_TAG}\"" +tar -Oxf "${source_tarball}" "${gitlab_octez_source_package_name}/src/lib_version/exe/get_git_info.ml" | grep "let raw_current_version = \"${CI_COMMIT_TAG}\"" # Checksums sha256sum "${source_tarball}" > "${source_tarball}.sha256" sha512sum "${source_tarball}" > "${source_tarball}.sha512" -gitlab_upload "${source_tarball}" "${source_tarball}" -gitlab_upload "${source_tarball}.sha256" "${source_tarball}.sha256" -gitlab_upload "${source_tarball}.sha512" "${source_tarball}.sha512" +gitlab_upload "${source_tarball}" "${source_tarball}" "${gitlab_octez_source_package_url}" +gitlab_upload "${source_tarball}.sha256" "${source_tarball}.sha256" "${gitlab_octez_source_package_url}" +gitlab_upload "${source_tarball}.sha512" "${source_tarball}.sha512" "${gitlab_octez_source_package_url}" diff --git a/scripts/ci/create_gitlab_release.sh b/scripts/ci/create_gitlab_release.sh index 10a621cdad739c8d3514584961d2e5301c5dde00..541cceef74cef71c88b7791a8abd49535de55292 100755 --- a/scripts/ci/create_gitlab_release.sh +++ b/scripts/ci/create_gitlab_release.sh @@ -16,7 +16,7 @@ echo "Query GitLab to get generic package URL" # :gitlab_api_url/projects/:id/packages web_path=$(curl -fsSL -X GET \ -H "JOB-TOKEN: ${CI_JOB_TOKEN}" \ - "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?sort=desc&package_name=${gitlab_octez_package_name}" | + "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?sort=desc&package_name=${gitlab_octez_binaries_package_name}" | jq -r ".[] | select(.version==\"${gitlab_package_version}\") | ._links.web_path") deb_web_path=$(curl -fsSL -X GET \ @@ -29,11 +29,17 @@ rpm_web_path=$(curl -fsSL -X GET \ "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?sort=desc&package_name=${gitlab_octez_rpm_package_name}" | jq -r ".[] | select(.version==\"${gitlab_package_version}\") | ._links.web_path") +source_web_path=$(curl -fsSL -X GET \ + -H "JOB-TOKEN: ${CI_JOB_TOKEN}" \ + "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?sort=desc&package_name=${gitlab_octez_source_package_name}" | + jq -r ".[] | select(.version==\"${gitlab_package_version}\") | ._links.web_path") + if [ -z "${web_path}" ]; then echo "Error: could not find package matching version ${gitlab_package_version}" exit 1 else gitlab_binaries_url="https://${CI_SERVER_HOST}${web_path}" + gitlab_octez_source_url="https://${CI_SERVER_HOST}${source_web_path}" fi if [ -z "${deb_web_path}" ]; then @@ -88,4 +94,5 @@ release-cli create \ --assets-link="{\"name\":\"Docker image\",\"url\":\"${docker_image_url}\",\"link_type\":\"image\"}" \ --assets-link="{\"name\":\"Static binaries\",\"url\":\"${gitlab_binaries_url}\",\"link_type\":\"package\"}" \ --assets-link="{\"name\":\"Debian packages\",\"url\":\"${gitlab_deb_packages_url}\",\"link_type\":\"package\"}" \ - --assets-link="{\"name\":\"Red Hat packages\",\"url\":\"${gitlab_rpm_packages_url}\",\"link_type\":\"package\"}" + --assets-link="{\"name\":\"Red Hat packages\",\"url\":\"${gitlab_rpm_packages_url}\",\"link_type\":\"package\"}" \ + --assets-link="{\"name\":\"Octez source\",\"url\":\"${gitlab_octez_source_url}\",\"link_type\":\"other\"}" diff --git a/scripts/ci/opam-release.sh b/scripts/ci/opam-release.sh index 0a71535f6996759a2e46a1b9b19fbff70f0788d4..7e1fd826e7993d01ca3958e3b2eae86f34cf1f87 100755 --- a/scripts/ci/opam-release.sh +++ b/scripts/ci/opam-release.sh @@ -27,12 +27,12 @@ log "Done setting up credentials." # call opam-release.sh with the correct arguments echo "$script_dir/opam-release.sh" \ "$opam_release_tag" \ - "https://gitlab.com/tezos/tezos/-/archive/$CI_COMMIT_TAG/$gitlab_octez_package_name.tar.gz" \ + "https://gitlab.com/tezos/tezos/-/archive/$CI_COMMIT_TAG/$gitlab_octez_source_package_name.tar.gz" \ "$opam_dir" "$script_dir/opam-release.sh" \ "$opam_release_tag" \ - "https://gitlab.com/tezos/tezos/-/archive/$CI_COMMIT_TAG/$gitlab_octez_package_name.tar.gz" \ + "https://gitlab.com/tezos/tezos/-/archive/$CI_COMMIT_TAG/$gitlab_octez_source_package_name.tar.gz" \ "$opam_dir" # Matches the corresponding variable in /scripts/opam-release.sh. diff --git a/scripts/ci/release.sh b/scripts/ci/release.sh index c3b8309e0282501cd809bb8969c1092555a02d62..14ef029285bb036c19ca031ddc1400ae8ee9d145 100755 --- a/scripts/ci/release.sh +++ b/scripts/ci/release.sh @@ -14,6 +14,8 @@ binaries="$(cat "$script_inputs_dir/released-executables")" deb_packages="$(find . -maxdepth 1 -name octez-\*.deb)" rpm_packages="$(find . -maxdepth 1 -name octez-\*.rpm)" +octez_source_content="$script_inputs_dir/octez-source-content" + ### Compute GitLab release names # Remove the 'v' in front @@ -47,9 +49,10 @@ fi ### Compute GitLab generic package names -gitlab_octez_package_name="octez-${gitlab_release_no_v}" +gitlab_octez_binaries_package_name="octez-binaries-${gitlab_release_no_v}" gitlab_octez_deb_package_name="octez-debian-${gitlab_release_no_v}" gitlab_octez_rpm_package_name="octez-redhat-${gitlab_release_no_v}" +gitlab_octez_source_package_name="octez-source-${gitlab_release_no_v}" # X.Y or X.Y-rcZ gitlab_package_version="${gitlab_release_no_v}" diff --git a/scripts/ci/restrict_export_to_octez_source.sh b/scripts/ci/restrict_export_to_octez_source.sh new file mode 100755 index 0000000000000000000000000000000000000000..7ec8ba399c166b71964fa1d3658ae09e4c003244 --- /dev/null +++ b/scripts/ci/restrict_export_to_octez_source.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -eu + +# shellcheck source=./scripts/ci/release.sh +. ./scripts/ci/release.sh + +# Adds export-ignore for each part of the repo that is not part of octez +ignore="$(comm -2 -3 <(find . -maxdepth 1 | sed 's|^./||' | sort) <(sort "${octez_source_content}"))" +for e in $ignore; do + if ! [ "$e" = "." ] && ! [ "$e" = ".." ]; then + echo "$e export-ignore" >> ./.gitattributes + fi +done