diff --git a/.goreleaser.develop.yaml b/.goreleaser.develop.yaml index d461c4402f2..1e054df7c45 100644 --- a/.goreleaser.develop.yaml +++ b/.goreleaser.develop.yaml @@ -3,7 +3,6 @@ project_name: chainlink env: - IMG_PRE={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }} - IMG_TAG={{ if index .Env "IMAGE_TAG" }}{{ .Env.IMAGE_TAG }}{{ else }}develop{{ end }} - - CGO_ENABLED=1 - VERSION={{ if index .Env "CHAINLINK_VERSION" }}{{ .Env.CHAINLINK_VERSION }}{{ else }}v0.0.0-local{{ end }} release: disable: "true" @@ -17,9 +16,8 @@ builds: no_unique_dist_dir: "true" ldflags: - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - - -extldflags "-Wl,--dynamic-linker=/lib{{ if contains .Runtime.Goarch "amd64" }}64{{end}}/ld-linux-{{ if contains .Runtime.Goarch "arm64" }}aarch64{{ else }}x86-64{{end}}.so.1" - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.VERSION }} + - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} flags: - -trimpath - -buildmode=pie @@ -51,8 +49,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-amd64-chainlink-plugins goos: linux @@ -80,8 +78,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-arm64-chainlink goos: linux @@ -103,8 +101,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-arm64-chainlink-plugins goos: linux @@ -131,8 +129,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-amd64-ccip goos: linux @@ -157,8 +155,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-amd64-ccip-plugins goos: linux @@ -188,8 +186,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-arm64-ccip goos: linux @@ -213,8 +211,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-arm64-ccip-plugins goos: linux @@ -243,8 +241,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx docker_manifests: - id: tagged-chainlink diff --git a/.goreleaser.devspace.yaml b/.goreleaser.devspace.yaml index 816f2cb878e..d0167b34cda 100644 --- a/.goreleaser.devspace.yaml +++ b/.goreleaser.devspace.yaml @@ -1,97 +1,89 @@ +project_name: chainlink-devspace + version: 2 -project_name: chainlink + env: - - IMG_PRE={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }} - - IMG_TAG={{ if index .Env "IMAGE_TAG" }}{{ .Env.IMAGE_TAG }}{{ else }}develop{{ end }} - - CGO_ENABLED=1 -release: - disable: "true" + - ZIG_EXEC={{ if index .Env "ZIG_EXEC" }}{{ .Env.ZIG_EXEC }}{{ else }}zig{{ end }} + - IMAGE_LABEL_DESCRIPTION="node of the decentralized oracle network, bridging on and off-chain computation" + - IMAGE_LABEL_LICENSES="MIT" + - IMAGE_LABEL_SOURCE="https://github.com/smartcontractkit/{{ .ProjectName }}" + +before: + hooks: + - go mod tidy + - ./tools/bin/goreleaser_utils before_hook + +# See https://goreleaser.com/customization/build/ builds: - - targets: - - go_first_class - binary: chainlink - hooks: - post: - - cmd: ./tools/bin/goreleaser_utils build_post_hook {{ dir .Path }} - no_unique_dist_dir: "true" - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - - -extldflags "-Wl,--dynamic-linker=/lib{{ if contains .Runtime.Goarch "amd64" }}64{{end}}/ld-linux-{{ if contains .Runtime.Goarch "arm64" }}aarch64{{ else }}x86-64{{end}}.so.1" - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Version }} - flags: - - -trimpath - - -buildmode=pie -archives: - - format: binary -snapshot: - version_template: v0.0.0-{{ .Runtime.Goarch }}-{{ .Now.Format "2006-01-02-15-04-05Z" }} -checksum: - name_template: checksums.txt + - binary: chainlink + id: linux-amd64 + goos: + - linux + goarch: + - amd64 + hooks: + post: ./tools/bin/goreleaser_utils build_post_hook {{ dir .Path }} {{ .Os }} {{ .Arch }} + env: + - CGO_ENABLED=1 + - CC=$ZIG_EXEC cc -target x86_64-linux-gnu -Wno-error=unused-command-line-argument + - CCX=$ZIG_EXEC c++ -target x86_64-linux-gnu -Wno-error=unused-command-line-argument + flags: + - -trimpath + - -buildmode=pie + ldflags: + - -s -w -r=$ORIGIN/libs + - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Version }} + - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} + +# See https://goreleaser.com/customization/docker/ dockers: - - id: linux-amd64 - goos: linux - goarch: amd64 - dockerfile: core/chainlink.goreleaser.Dockerfile - image_templates: - - '{{ .Env.IMAGE }}' - extra_files: - - tmp/libs - - tmp/plugins - build_flag_templates: - - --platform=linux/amd64 - - --pull - - --build-arg=CHAINLINK_USER=chainlink - - --build-arg=COMMIT_SHA={{ .FullCommit }} - - --build-arg=CL_MEDIAN_CMD=chainlink-feeds - - --build-arg=CL_MERCURY_CMD=chainlink-mercury - - --build-arg=CL_SOLANA_CMD=chainlink-solana - - --build-arg=CL_STARKNET_CMD=chainlink-starknet - - --label=org.opencontainers.image.created={{ .Date }} - - --label=org.opencontainers.image.description="node of the decentralized oracle network, bridging on and off-chain computation" - - --label=org.opencontainers.image.licenses=MIT - - --label=org.opencontainers.image.revision={{ .FullCommit }} - - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - use: buildx - - id: linux-arm64 - goos: linux - goarch: arm64 - dockerfile: core/chainlink.goreleaser.Dockerfile - image_templates: - - '{{ .Env.IMAGE }}' - extra_files: - - tmp/libs - - tmp/plugins - build_flag_templates: - - --platform=linux/arm64 - - --pull - - --build-arg=CHAINLINK_USER=chainlink - - --build-arg=COMMIT_SHA={{ .FullCommit }} - - --build-arg=CL_MEDIAN_CMD=chainlink-feeds - - --build-arg=CL_MERCURY_CMD=chainlink-mercury - - --build-arg=CL_SOLANA_CMD=chainlink-solana - - --build-arg=CL_STARKNET_CMD=chainlink-starknet - - --label=org.opencontainers.image.created={{ .Date }} - - --label=org.opencontainers.image.description="node of the decentralized oracle network, bridging on and off-chain computation" - - --label=org.opencontainers.image.licenses=MIT - - --label=org.opencontainers.image.revision={{ .FullCommit }} - - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - use: buildx + - id: linux-amd64 + dockerfile: core/chainlink.goreleaser.Dockerfile + use: buildx + goos: linux + goarch: amd64 + extra_files: + - tmp/linux_amd64/libs + - tmp/linux_amd64/plugins + - tools/bin/ldd_fix + build_flag_templates: + - "--platform=linux/amd64" + - "--pull" + - "--build-arg=CHAINLINK_USER=chainlink" + - "--build-arg=COMMIT_SHA={{ .FullCommit }}" + - "--build-arg=CL_MEDIAN_CMD=chainlink-feeds" + - "--build-arg=CL_MERCURY_CMD=chainlink-mercury" + - "--build-arg=CL_SOLANA_CMD=chainlink-solana" + - "--build-arg=CL_STARKNET_CMD=chainlink-starknet" + - "--label=org.opencontainers.image.created={{ .Date }}" + - "--label=org.opencontainers.image.description={{ .Env.IMAGE_LABEL_DESCRIPTION }}" + - "--label=org.opencontainers.image.licenses={{ .Env.IMAGE_LABEL_LICENSES }}" + - "--label=org.opencontainers.image.revision={{ .FullCommit }}" + - "--label=org.opencontainers.image.source={{ .Env.IMAGE_LABEL_SOURCE }}" + - "--label=org.opencontainers.image.title={{ .ProjectName }}" + - "--label=org.opencontainers.image.version={{ .Version }}" + - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" + image_templates: + - "{{ .Env.IMAGE }}" + +# See https://goreleaser.com/customization/docker_manifest/ docker_manifests: - - name_template: '{{ .Env.IMAGE }}' - image_templates: - - '{{ .Env.IMAGE }}' + - name_template: "{{ .Env.IMAGE }}" + image_templates: + - "{{ .Env.IMAGE }}" + +checksum: + name_template: "checksums.txt" + +snapshot: + version_template: '{{ .Env.CHAINLINK_VERSION }}-{{ .Runtime.Goarch }}-{{ .Now.Format "2006-01-02-15-04-05Z" }}' + changelog: - disable: "true" -before: - hooks: - - cmd: go mod tidy - - cmd: ./tools/bin/goreleaser_utils before_hook -partial: - by: target -nightly: - version_template: v0.0.0-{{ .Runtime.Goarch }}-{{ .Now.Format "2006-01-02-15-04-05Z" }} + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" +# modelines, feel free to remove those if you don't want/use them: +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/.goreleaser.production.yaml b/.goreleaser.production.yaml index b29130bc54d..ada9b847e74 100644 --- a/.goreleaser.production.yaml +++ b/.goreleaser.production.yaml @@ -3,7 +3,6 @@ project_name: chainlink env: - IMG_PRE={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }} - IMG_TAG={{ if index .Env "IMAGE_TAG" }}{{ .Env.IMAGE_TAG }}{{ else }}develop{{ end }} - - CGO_ENABLED=1 - VERSION={{ if index .Env "CHAINLINK_VERSION" }}{{ .Env.CHAINLINK_VERSION }}{{ else }}v0.0.0-local{{ end }} release: disable: "true" @@ -17,9 +16,8 @@ builds: no_unique_dist_dir: "true" ldflags: - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - - -extldflags "-Wl,--dynamic-linker=/lib{{ if contains .Runtime.Goarch "amd64" }}64{{end}}/ld-linux-{{ if contains .Runtime.Goarch "arm64" }}aarch64{{ else }}x86-64{{end}}.so.1" - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.VERSION }} + - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} flags: - -trimpath - -buildmode=pie @@ -52,8 +50,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-amd64-chainlink-plugins goos: linux @@ -82,8 +80,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-arm64-chainlink goos: linux @@ -106,8 +104,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-arm64-chainlink-plugins goos: linux @@ -135,8 +133,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-amd64-ccip goos: linux @@ -162,8 +160,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-amd64-ccip-plugins goos: linux @@ -194,8 +192,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-arm64-ccip goos: linux @@ -220,8 +218,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx - id: linux-arm64-ccip-plugins goos: linux @@ -251,8 +249,8 @@ dockers: - --label=org.opencontainers.image.revision={{ .FullCommit }} - --label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.title=chainlink - - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink - --label=org.opencontainers.image.version={{ .Env.VERSION }} + - --label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink use: buildx docker_manifests: - id: tagged-chainlink-chainlink-experimental-goreleaser diff --git a/flake.lock b/flake.lock index 71af2318c95..77dddea4060 100644 --- a/flake.lock +++ b/flake.lock @@ -40,24 +40,6 @@ "type": "github" } }, - "goreleaser-nur": { - "inputs": { - "nixpkgs": "nixpkgs_2" - }, - "locked": { - "lastModified": 1726594821, - "narHash": "sha256-ORImH+i+zOCMOdztNDqGDbyyFRC/FKmgbX8w50TNbQY=", - "owner": "goreleaser", - "repo": "nur", - "rev": "bd2ee272ddfffbda9377a472131728e83ce2332d", - "type": "github" - }, - "original": { - "owner": "goreleaser", - "repo": "nur", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1666753130, @@ -73,22 +55,6 @@ } }, "nixpkgs_2": { - "locked": { - "lastModified": 1624561540, - "narHash": "sha256-izJ2PYZMGMsSkg+e7c9A1x3t/yOLT+qzUM6WQsc2tqo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "c6a049a3d32293b24c0f894a840872cf67fd7c11", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1725103162, "narHash": "sha256-Ym04C5+qovuQDYL/rKWSR+WESseQBbNAe5DsXNx5trY=", @@ -104,28 +70,11 @@ "type": "github" } }, - "nur": { - "locked": { - "lastModified": 1727912806, - "narHash": "sha256-LDOTTOGPaEP233gBrL8dnPGopc1lqcJFe0VB/+K/yWc=", - "owner": "nix-community", - "repo": "NUR", - "rev": "9d9bcd30fec126b08b49020b7af08bc1aad66210", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "NUR", - "type": "github" - } - }, "root": { "inputs": { "flake-utils": "flake-utils", "foundry": "foundry", - "goreleaser-nur": "goreleaser-nur", - "nixpkgs": "nixpkgs_3", - "nur": "nur" + "nixpkgs": "nixpkgs_2" } }, "systems": { diff --git a/flake.nix b/flake.nix index 0d1aac2f05d..7e188857ba4 100644 --- a/flake.nix +++ b/flake.nix @@ -6,8 +6,6 @@ foundry.url = "github:shazow/foundry.nix/monthly"; flake-utils.url = "github:numtide/flake-utils"; foundry.inputs.flake-utils.follows = "flake-utils"; - nur.url = "github:nix-community/NUR"; - goreleaser-nur.url = "github:goreleaser/nur"; }; outputs = inputs @ { @@ -15,30 +13,15 @@ nixpkgs, flake-utils, foundry, - nur, - goreleaser-nur, ... }: flake-utils.lib.eachDefaultSystem (system: let - isCrib = builtins.getEnv "IS_CRIB" == "true"; - pkgs = import nixpkgs { inherit system; - config = { allowUnfree = true; }; - overlays = [ - (final: prev: { - nur = import nur - { - pkgs = prev; - repoOverrides = { - goreleaser = import goreleaser-nur { pkgs = prev; }; - }; - }; - }) - foundry.overlay - ]; - }; + pkgs = import nixpkgs { + inherit system; + overlays = [foundry.overlay]; + }; in rec { devShell = pkgs.callPackage ./shell.nix { - isCrib = isCrib; inherit pkgs; }; formatter = pkgs.nixpkgs-fmt; diff --git a/nix-darwin-shell-hook.sh b/nix-darwin-shell-hook.sh deleted file mode 100755 index 49dbfc60983..00000000000 --- a/nix-darwin-shell-hook.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# This script is used to set up cross compilation to linux arm64 in a CRIB environment. -# It's loaded during the shell hook execution in shell.nix -main() { - echo "Running in CRIB environment, setting up cross compilation to linux arm64..." - PACKAGE="aarch64-unknown-linux-gnu" - - if ! command -v brew >/dev/null 2>&1; then - echo -e "\e[31mHomebrew is not installed. Please install Homebrew first: https://brew.sh/\e[0m" - exit 1 - fi - - if ! brew list --formula | grep $PACKAGE > /dev/null; then - echo -e "\e[31mThe Homebrew package $PACKAGE is not installed.\e[0m" - echo -e "\e[31mPlease install it by running: brew tap messense/macos-cross-toolchains && brew install ${PACKAGE}\e[0m" - exit 1 - fi - - export GOOS=linux - - installed_version=$(brew list --versions $PACKAGE | awk '{print $2}') - path_prefix=$(brew --prefix) - bin_path=$path_prefix/Cellar/$PACKAGE/$installed_version/bin - - export CC=$bin_path/aarch64-linux-gnu-gcc - export CXX=$bin_path/aarch64-linux-gnu-g++ -} - -main "$@" diff --git a/shell.nix b/shell.nix index e3b187dcd96..ba09ebc219d 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,4 @@ -{pkgs, isCrib}: +{pkgs}: with pkgs; let go = go_1_21; postgresql = postgresql_14; @@ -18,6 +18,7 @@ in nativeBuildInputs = [ go + goreleaser postgresql python3 @@ -50,22 +51,10 @@ in pkg-config libudev-zero libusb1 - ] ++ lib.optionals isCrib [ - nur.repos.goreleaser.goreleaser-pro - patchelf ]; - - shellHook = '' - ${if !isCrib then "" else '' - if [ -z $GORELEASER_KEY ]; then - echo "GORELEASER_KEY must be set in CRIB environments. You can find it in our 1p vault under 'goreleaser-pro-license'." - exit 1 - fi - ${if stdenv.isDarwin then "source ./nix-darwin-shell-hook.sh" else ""} - ''} - ''; - + LD_LIBRARY_PATH = "${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH"; GOROOT = "${go}/share/go"; + PGDATA = "db"; CL_DATABASE_URL = "postgresql://chainlink:chainlink@localhost:5432/chainlink_test?sslmode=disable"; } diff --git a/tools/bin/goreleaser_utils b/tools/bin/goreleaser_utils index 562dfb96e03..a01c1654133 100755 --- a/tools/bin/goreleaser_utils +++ b/tools/bin/goreleaser_utils @@ -13,38 +13,7 @@ before_hook() { install_local_plugins install_remote_plugins mkdir -p "$lib_path/plugins" - - # Retrieve GOPATH - GOPATH=$(go env GOPATH) - GOARCH=$(go env GOARCH) - - # Define the source directories - BIN_DIR="$GOPATH/bin" - PLUGIN_DIR="$lib_path/plugins" - - # Because we still do cross compilation in the case of - # darwin_arm64 -> linux_arm64, the plugin path will have a suffix of - # linux_arm64, rather than being suffixless on native platforms - if [ "$GOARCH" = "arm64" ]; then - if [ -d "$BIN_DIR/linux_arm64" ]; then - cp "$BIN_DIR/linux_arm64"/chainlink* "$PLUGIN_DIR" - else - cp "$BIN_DIR"/chainlink* "$PLUGIN_DIR" - fi - # Call patchelf --set-interpreter on all plugins - for plugin in "$PLUGIN_DIR"/chainlink*; do - patchelf --set-interpreter /lib/ld-linux-aarch64.so.1 "$plugin" - done - - else - cp "$BIN_DIR"/chainlink* "$PLUGIN_DIR" - - # Call patchelf --set-interpreter on all plugins - for plugin in "$PLUGIN_DIR"/chainlink*; do - patchelf --set-interpreter /lib64/ld-linux-x86_64.so.1 "$plugin" - done - fi - + cp "$(go env GOPATH)"/bin/chainlink* "$lib_path/plugins" } install_local_plugins() { diff --git a/tools/goreleaser-config/gen_config.go b/tools/goreleaser-config/gen_config.go index b0b75b032fa..9108ec1bbd1 100644 --- a/tools/goreleaser-config/gen_config.go +++ b/tools/goreleaser-config/gen_config.go @@ -13,12 +13,10 @@ var validEnvironments = []string{"devspace", "develop", "production"} func Generate(environment string) config.Project { checkEnvironments(environment) - architectures := []string{"amd64", "arm64"} - project := config.Project{ ProjectName: "chainlink", Version: 2, - Env: commonEnv(environment), + Env: commonEnv(), Before: config.Before{ Hooks: []config.Hook{ { @@ -30,7 +28,7 @@ func Generate(environment string) config.Project { }, }, Builds: builds(environment), - Dockers: dockers(environment, architectures), + Dockers: dockers(environment), DockerManifests: dockerManifests(environment), Checksum: config.Checksum{ NameTemplate: "checksums.txt", @@ -56,11 +54,6 @@ func Generate(environment string) config.Project { Disable: "true", }, } - if environment == "devspace" { - versionTemplate := `v0.0.0-{{ .Runtime.Goarch }}-{{ .Now.Format "2006-01-02-15-04-05Z" }}` - project.Snapshot = config.Snapshot{VersionTemplate: versionTemplate} - project.Nightly = config.Nightly{VersionTemplate: versionTemplate} - } // Add SBOMs if needed if environment == "production" { @@ -102,17 +95,12 @@ func checkEnvironments(environment string) { } // commonEnv returns the common environment variables used across environments. -func commonEnv(environment string) []string { - envs := []string{ +func commonEnv() []string { + return []string{ `IMG_PRE={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }}`, `IMG_TAG={{ if index .Env "IMAGE_TAG" }}{{ .Env.IMAGE_TAG }}{{ else }}develop{{ end }}`, - `CGO_ENABLED=1`, - } - - if environment != "devspace" { - envs = append(envs, `VERSION={{ if index .Env "CHAINLINK_VERSION" }}{{ .Env.CHAINLINK_VERSION }}{{ else }}v0.0.0-local{{ end }}`) + `VERSION={{ if index .Env "CHAINLINK_VERSION" }}{{ .Env.CHAINLINK_VERSION }}{{ else }}v0.0.0-local{{ end }}`, } - return envs } // builds returns the build configurations based on the environment. @@ -134,18 +122,13 @@ func builds(environment string) []config.Build { // build creates a build configuration. func build(isDevspace bool) config.Build { - dynamicLinker := `/lib{{ if contains .Runtime.Goarch "amd64" }}64{{end}}/ld-linux-{{ if contains .Runtime.Goarch "arm64" }}aarch64{{ else }}x86-64{{end}}.so.1` - ldflags := []string{ "-s -w -r=$ORIGIN/libs", + "-X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.VERSION }}", "-X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }}", - fmt.Sprintf(`-extldflags "-Wl,--dynamic-linker=%s"`, dynamicLinker), } - if isDevspace { - ldflags = append(ldflags, "-X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Version }}") - } else { - ldflags = append(ldflags, "-X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.VERSION }}") + ldflags[2] = "-X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Version }}" } return config.Build{ @@ -165,16 +148,16 @@ func build(isDevspace bool) config.Build { } // dockers returns the docker configurations based on the environment. -func dockers(environment string, architectures []string) []config.Docker { +func dockers(environment string) []config.Docker { var dockers []config.Docker switch environment { case "devspace": dockers = []config.Docker{ docker("linux-amd64", "linux", "amd64", environment, true), - docker("linux-arm64", "linux", "arm64", environment, true), } case "develop", "production": + architectures := []string{"amd64", "arm64"} imageNames := []string{"chainlink", "ccip"} for _, imageName := range imageNames { @@ -230,13 +213,9 @@ func docker(id, goos, goarch, environment string, isDevspace bool) config.Docker `--label=org.opencontainers.image.revision={{ .FullCommit }}`, `--label=org.opencontainers.image.source=https://github.com/smartcontractkit/chainlink`, `--label=org.opencontainers.image.title=chainlink`, + `--label=org.opencontainers.image.version={{ .Env.VERSION }}`, `--label=org.opencontainers.image.url=https://github.com/smartcontractkit/chainlink`, ) - if !isDevspace { - buildFlagTemplates = append(buildFlagTemplates, - `--label=org.opencontainers.image.version={{ .Env.VERSION }}`, - ) - } dockerConfig := config.Docker{ ID: id, diff --git a/tools/goreleaser-config/main.go b/tools/goreleaser-config/main.go index 1e3e9776b14..852b5b580ae 100644 --- a/tools/goreleaser-config/main.go +++ b/tools/goreleaser-config/main.go @@ -7,7 +7,7 @@ import ( ) func main() { - environments := []string{"develop", "production", "devspace"} + environments := []string{"develop", "production"} for _, e := range environments { cfg := Generate(e) data, err := yaml.Marshal(&cfg)