From 8e65aa86a7b9b58e754b1579de69121fbe0c3e17 Mon Sep 17 00:00:00 2001 From: HenryNguyen5 <6404866+HenryNguyen5@users.noreply.github.com> Date: Fri, 1 Nov 2024 15:45:33 -0400 Subject: [PATCH] Cherrypick goreleaser based fixes (#1512) Co-authored-by: chainchad <96362174+chainchad@users.noreply.github.com> --- .../goreleaser-build-sign-publish/README.md | 56 -- .../goreleaser-build-sign-publish/action.yml | 79 +-- .../action_utils | 82 --- .../goreleaser-build-sign-publish/release.js | 243 ++++++++ .../workflows/build-publish-develop-pr.yml | 182 +++--- .../workflows/build-publish-goreleaser.yml | 150 +++++ .github/workflows/build-publish.yml | 139 +---- .goreleaser.ccip.develop.yaml | 229 -------- .goreleaser.ccip.production.yaml | 229 -------- .goreleaser.develop.yaml | 416 +++++++------- .goreleaser.devspace.yaml | 187 +++--- .goreleaser.production.yaml | 537 +++++++++++------- .tool-versions | 1 - GNUmakefile | 10 - core/chainlink.goreleaser.Dockerfile | 14 +- flake.lock | 53 +- flake.nix | 25 +- nix-darwin-shell-hook.sh | 30 + shell.nix | 22 +- tools/bin/goreleaser_utils | 130 ++--- tools/bin/goreleaser_wrapper | 41 -- tools/bin/ldd_fix | 27 - tools/goreleaser-config/gen_config.go | 391 +++++++++++++ tools/goreleaser-config/go.mod | 14 + tools/goreleaser-config/go.sum | 19 + tools/goreleaser-config/main.go | 24 + 26 files changed, 1762 insertions(+), 1568 deletions(-) delete mode 100755 .github/actions/goreleaser-build-sign-publish/action_utils create mode 100755 .github/actions/goreleaser-build-sign-publish/release.js create mode 100644 .github/workflows/build-publish-goreleaser.yml delete mode 100644 .goreleaser.ccip.develop.yaml delete mode 100644 .goreleaser.ccip.production.yaml create mode 100755 nix-darwin-shell-hook.sh delete mode 100755 tools/bin/goreleaser_wrapper delete mode 100755 tools/bin/ldd_fix create mode 100644 tools/goreleaser-config/gen_config.go create mode 100644 tools/goreleaser-config/go.mod create mode 100644 tools/goreleaser-config/go.sum create mode 100644 tools/goreleaser-config/main.go diff --git a/.github/actions/goreleaser-build-sign-publish/README.md b/.github/actions/goreleaser-build-sign-publish/README.md index 189578391f..07bb644c00 100644 --- a/.github/actions/goreleaser-build-sign-publish/README.md +++ b/.github/actions/goreleaser-build-sign-publish/README.md @@ -21,8 +21,6 @@ jobs: permissions: id-token: write contents: read - env: - MACOS_SDK_VERSION: 12.3 steps: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -32,28 +30,11 @@ jobs: role-to-assume: ${{ secrets.aws-role-arn }} role-duration-seconds: ${{ secrets.aws-role-dur-sec }} aws-region: ${{ secrets.aws-region }} - - name: Cache macos sdk - id: sdk-cache - uses: actions/cache@v3 - with: - path: ${{ format('MacOSX{0}.sdk', env.MAC_SDK_VERSION) }} - key: ${{ runner.OS }}-${{ env.MAC_SDK_VERSION }}-macos-sdk-cache-${{ hashFiles('**/SDKSettings.json') }} - restore-keys: | - ${{ runner.OS }}-${{ env.MAC_SDK_VERSION }}-macos-sdk-cache- - - name: Get macos sdk - if: steps.sdk-cache.outputs.cache-hit != 'true' - run: | - curl -L https://github.com/joseluisq/macosx-sdks/releases/download/${MACOS_SDK_VERSION}/MacOSX${MACOS_SDK_VERSION}.sdk.tar.xz > MacOSX${MACOS_SDK_VERSION}.sdk.tar.xz - tar -xf MacOSX${MACOS_SDK_VERSION}.sdk.tar.xz - name: Build, sign, and publish uses: ./.github/actions/goreleaser-build-sign-publish with: - enable-docker-publish: "true" - enable-goreleaser-snapshot: "false" docker-registry: ${{ secrets.aws-ecr-registry }} - goreleaser-exec: goreleaser goreleaser-config: .goreleaser.yaml - macos-sdk-dir: ${{ format('MacOSX{0}.sdk', env.MAC_SDK_VERSION) }} env: GITHUB_TOKEN: ${{ secrets.gh-token }} ``` @@ -64,29 +45,8 @@ jobs: - name: Build, sign, and publish image uses: ./.github/actions/goreleaser-build-sign-publish with: - enable-docker-publish: "true" - enable-goreleaser-snapshot: "true" - docker-registry: ${{ secrets.aws-ecr-registry }} - goreleaser-exec: goreleaser - goreleaser-config: .goreleaser.yaml -``` - -### image signing - -```yaml -- name: Build, sign, and publish - uses: ./.github/actions/goreleaser-build-sign-publish - with: - enable-docker-publish: "true" - enable-goreleaser-snapshot: "false" - enable-cosign: "true" docker-registry: ${{ secrets.aws-ecr-registry }} - goreleaser-exec: goreleaser goreleaser-config: .goreleaser.yaml - cosign-password: ${{ secrets.cosign-password }} - cosign-public-key: ${{ secrets.cosign-public-key }} - cosign-private-key: ${{ secrets.cosign-private-key }} - macos-sdk-dir: MacOSX12.3.sdk ``` ## customizing @@ -98,22 +58,9 @@ Following inputs can be used as `step.with` keys | Name | Type | Default | Description | | ---------------------------- | ------ | ------------------ | ----------------------------------------------------------------------- | | `goreleaser-version` | String | `~> v2` | `goreleaser` version | -| `zig-version` | String | `0.10.1` | `zig` version | -| `cosign-version` | String | `v2.2.2` | `cosign` version | -| `macos-sdk-dir` | String | `MacOSX12.3.sdk` | MacOSX sdk directory | -| `enable-docker-publish` | Bool | `true` | Enable publishing of Docker images / manifests | | `docker-registry` | String | `localhost:5001` | Docker registry | -| `docker-image-name` | String | `chainlink` | Docker image name | | `docker-image-tag` | String | `develop` | Docker image tag | -| `enable-goreleaser-snapshot` | Bool | `false` | Enable goreleaser build / release snapshot | -| `enable-goreleaser-split` | Bool | `false` | Enable goreleaser build using split and merge | -| `goreleaser-split-arch` | String | `""` | The arch to build the image with - amd64, arm64 | -| `goreleaser-exec` | String | `goreleaser` | The goreleaser executable, can invoke wrapper script | | `goreleaser-config` | String | `.goreleaser.yaml` | The goreleaser configuration yaml | -| `enable-cosign` | Bool | `false` | Enable signing of Docker images | -| `cosign-public-key` | String | `""` | The public key to be used with cosign for verification | -| `cosign-private-key` | String | `""` | The private key to be used with cosign to sign the image | -| `cosign-password-key` | String | `""` | The password to decrypt the cosign private key needed to sign the image | ## testing @@ -126,10 +73,7 @@ docker run -d --restart=always -p "127.0.0.1:5001:5000" --name registry registry - run snapshot release, publish to local docker registry ```sh -GORELEASER_EXEC=" set -_publish_snapshot_images() { - local full_sha=$(git rev-parse HEAD) - local images=$(docker images --filter "label=org.opencontainers.image.revision=$full_sha" --format "{{.Repository}}:{{.Tag}}") - for image in $images; do - docker push "$image" - done -} - -# publish snapshot docker manifest lists -# must have label=org.opencontainers.image.revision= set -_publish_snapshot_manifests() { - local docker_manifest_extra_args=$DOCKER_MANIFEST_EXTRA_ARGS - local full_sha=$(git rev-parse HEAD) - local images=$(docker images --filter "label=org.opencontainers.image.revision=$full_sha" --format "{{.Repository}}:{{.Tag}}" | sort) - local raw_manifest_lists="" - if [[ $ENABLE_GORELEASER_SPLIT == "true" ]]; then - local arches=(${GOARCH:-""}) - else - local arches=(amd64 arm64) - fi - for image in $images; do - for arch in "${arches[@]}"; do - image=${image%"-$arch"} - done - raw_manifest_lists+="$image"$'\n' - done - local manifest_lists=$(echo "$raw_manifest_lists" | sort | uniq) - for manifest_list in $manifest_lists; do - manifests="" - for arch in "${arches[@]}"; do - archExists=$(echo "$images" | grep -c "$manifest_lists-$arch") - if [[ $archExists -ne 0 ]]; then - manifests+="$manifest_list-$arch " - fi - done - docker manifest create $manifest_list $manifests $docker_manifest_extra_args - docker manifest push "$manifest_list" - done -} - -# wrapper function to invoke goreleaser release -goreleaser_release() { - goreleaser_flags=() - - # set goreleaser flags - if [[ $ENABLE_GORELEASER_SNAPSHOT == "true" ]]; then - goreleaser_flags+=("--snapshot") - goreleaser_flags+=("--clean") - fi - if [[ $ENABLE_GORELEASER_SPLIT == "true" ]]; then - goreleaser_flags+=("--split") - fi - flags=$(printf "%s " "${goreleaser_flags[@]}") - flags=$(echo "$flags" | sed 's/ *$//') - - if [[ -n $MACOS_SDK_DIR ]]; then - MACOS_SDK_DIR=$(echo "$(cd "$(dirname "$MACOS_SDK_DIR")" || exit; pwd)/$(basename "$MACOS_SDK_DIR")") - fi - - $GORELEASER_EXEC release ${flags} --config "$GORELEASER_CONFIG" "$@" - - if [[ $ENABLE_DOCKER_PUBLISH == "true" ]] && [[ $ENABLE_GORELEASER_SNAPSHOT == "true" ]]; then - _publish_snapshot_images - _publish_snapshot_manifests - fi -} - -"$@" diff --git a/.github/actions/goreleaser-build-sign-publish/release.js b/.github/actions/goreleaser-build-sign-publish/release.js new file mode 100755 index 0000000000..0dbd58ca6c --- /dev/null +++ b/.github/actions/goreleaser-build-sign-publish/release.js @@ -0,0 +1,243 @@ +#!/usr/bin/env node +const { execSync } = require("child_process"); +const fs = require("fs"); +const path = require("path"); + +function main() { + const args = process.argv.slice(2); + const useExistingDist = args.includes("--use-existing-dist"); + const chainlinkVersion = getVersion(); + + if (!useExistingDist) { + const goreleaserConfig = mustGetEnv("GORELEASER_CONFIG"); + const releaseType = mustGetEnv("RELEASE_TYPE"); + const command = constructGoreleaserCommand( + releaseType, + chainlinkVersion, + goreleaserConfig + ); + + if (process.env.DRY_RUN) { + console.log(`Generated command: ${command}`); + console.log("Dry run enabled. Exiting without executing the command."); + return; + } else { + console.log(`Executing command: ${command}`); + execSync(command, { stdio: "inherit" }); + } + } else { + console.log( + "Skipping Goreleaser command execution as '--use-existing-dist' is set." + ); + } + + const artifacts = getArtifacts(); + const dockerImages = extractDockerImages(artifacts); + const repoSha = execSync("git rev-parse HEAD", { encoding: "utf-8" }).trim(); + + const results = dockerImages.map((image) => { + try { + console.log( + `Checking version for image: ${image}, expected version: ${chainlinkVersion}, expected SHA: ${repoSha}` + ); + const versionOutput = execSync(`docker run --rm ${image} --version`, { + encoding: "utf-8", + }); + console.log(`Output from image ${image}: ${versionOutput}`); + + const cleanedOutput = versionOutput + .replace("chainlink version ", "") + .trim(); + const [version, sha] = cleanedOutput.split("@"); + if (!version || !sha) { + throw new Error("Version or SHA not found in output."); + } + + if (sha.trim() !== repoSha) { + throw new Error(`SHA mismatch: Expected ${repoSha}, got ${sha.trim()}`); + } + if (version.trim() !== chainlinkVersion) { + throw new Error( + `Version mismatch: Expected ${chainlinkVersion}, got ${version.trim()}` + ); + } + + return { image, success: true, message: "Version check passed." }; + } catch (error) { + return { image, success: false, message: error.message }; + } + }); + + printSummary(results); + if (results.some((result) => !result.success)) { + process.exit(1); + } +} + +function printSummary(results) { + const passed = results.filter((result) => result.success); + const failed = results.filter((result) => !result.success); + + console.log("\nSummary:"); + console.log(`Total images checked: ${results.length}`); + console.log(`Passed: ${passed.length}`); + console.log(`Failed: ${failed.length}`); + + if (passed.length > 0) { + console.log("\nPassed images:"); + passed.forEach((result) => + console.log(`${result.image}:\n${result.message}`) + ); + } + + if (failed.length > 0) { + console.log("\nFailed images:"); + failed.forEach((result) => + console.log(`${result.image}:\n${result.message}`) + ); + } +} + +function getArtifacts() { + const distDir = path.resolve(process.cwd(), "dist"); + const files = []; + + function findJsonFiles(dir) { + const items = fs.readdirSync(dir, { withFileTypes: true }); + for (const item of items) { + const fullPath = path.join(dir, item.name); + if (item.isDirectory()) { + // Skip child directories if an artifacts.json exists in the current directory + const parentArtifacts = path.join(dir, "artifacts.json"); + if (fs.existsSync(parentArtifacts)) { + console.log( + `Skipping child directory: ${fullPath} because a parent artifacts.json exists at: ${parentArtifacts}` + ); + } else { + findJsonFiles(fullPath); + } + } else if (item.isFile() && item.name === "artifacts.json") { + console.log(`Found artifacts.json at: ${fullPath}`); + files.push(fullPath); + } + } + } + + findJsonFiles(distDir); + + if (files.length === 0) { + console.error("Error: No artifacts.json found in /dist."); + process.exit(1); + } + + // Merge all artifacts.json files into one + let mergedArtifacts = []; + + for (const file of files) { + const artifactsJson = JSON.parse(fs.readFileSync(file, "utf-8")); + mergedArtifacts = mergedArtifacts.concat(artifactsJson); + } + + // Remove duplicate Docker images based on the artifact name + const uniqueArtifacts = Array.from( + new Map( + mergedArtifacts.map((artifact) => [artifact.name, artifact]) + ).values() + ); + + return uniqueArtifacts; +} + +function extractDockerImages(artifacts) { + const dockerImages = artifacts + .filter( + (artifact) => + artifact.type === "Docker Image" || + artifact.type === "Published Docker Image" + ) + .map((artifact) => artifact.name); + + if (dockerImages.length === 0) { + console.error("Error: No Docker images found in artifacts.json."); + process.exit(1); + } + + console.log(`Found Docker images:\n - ${dockerImages.join("\n - ")}`); + return dockerImages; +} + +function constructGoreleaserCommand(releaseType, version, goreleaserConfig) { + const flags = []; + + checkReleaseType(releaseType); + + let subCmd = "release"; + const splitArgs = ["--split", "--clean"]; + + switch (releaseType) { + case "release": + flags.push(...splitArgs); + break; + case "nightly": + flags.push("--nightly", ...splitArgs); + break; + case "snapshot": + flags.push("--snapshot", ...splitArgs); + break; + case "merge": + flags.push("--merge"); + subCmd = "continue"; + break; + } + + const flagsStr = flags.join(" "); + if (releaseType === "merge") { + return `CHAINLINK_VERSION=${version} goreleaser ${subCmd} ${flagsStr}`; + } else { + return `CHAINLINK_VERSION=${version} goreleaser ${subCmd} --config ${goreleaserConfig} ${flagsStr}`; + } +} + +function checkReleaseType(releaseType) { + const VALID_RELEASE_TYPES = ["nightly", "merge", "snapshot", "release"]; + + if (!VALID_RELEASE_TYPES.includes(releaseType)) { + const validReleaseTypesStr = VALID_RELEASE_TYPES.join(", "); + console.error( + `Error: Invalid release type: ${releaseType}. Must be one of: ${validReleaseTypesStr}` + ); + process.exit(1); + } +} + +function mustGetEnv(key) { + const val = process.env[key]; + if (!val || val.trim() === "") { + console.error(`Error: Environment variable ${key} is not set or empty.`); + process.exit(1); + } + + return val.trim(); +} + +function getVersion() { + try { + const pkgPath = path.resolve(process.cwd(), "package.json"); + console.log("Looking for chainlink version in package.json at: ", pkgPath); + const packageJson = require(pkgPath); + if (!packageJson.version) { + console.error( + 'Error: "version" field is missing or empty in package.json.' + ); + process.exit(1); + } + console.log("Resolved version: ", packageJson.version); + + return packageJson.version; + } catch (err) { + console.error(`Error reading package.json: ${err.message}`); + process.exit(1); + } +} + +main(); diff --git a/.github/workflows/build-publish-develop-pr.yml b/.github/workflows/build-publish-develop-pr.yml index 2868616ace..7f5a285bb4 100644 --- a/.github/workflows/build-publish-develop-pr.yml +++ b/.github/workflows/build-publish-develop-pr.yml @@ -1,11 +1,19 @@ -name: "Build and Publish Chainlink" +name: "Build and Publish GoReleaser" on: pull_request: + # The default types are opened, synchronize, and reopened + + # See https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request + # We add a label trigger too, since when the build-publish label is added to a PR, we want to build and publish + types: + - opened + - synchronize + - reopened + - labeled push: branches: - develop - - "release/**" workflow_dispatch: inputs: git_ref: @@ -20,17 +28,10 @@ env: GIT_REF: ${{ github.event.inputs.git_ref || github.ref }} jobs: - goreleaser-build-publish-chainlink: - name: "goreleaser-build-publish-${{ matrix.image-name }}" - strategy: - fail-fast: false - matrix: - include: - - image-name: chainlink - goreleaser-config: .goreleaser.develop.yaml - - image-name: ccip - goreleaser-config: .goreleaser.ccip.develop.yaml - runs-on: ubuntu-20.04 + merge: + runs-on: ubuntu-latest + needs: [split, image-tag] + if: ${{ needs.image-tag.outputs.release-type == 'nightly' }} permissions: id-token: write contents: read @@ -40,67 +41,83 @@ jobs: with: ref: ${{ env.GIT_REF }} - # This gets the image tag and whether to publish the image based on the event type - # PR builds: pr-- (if label 'build-publish' is present publishes the image) - # develop builds: develop- and develop (only amd64) - # release builds: release- - # manual builds: (if build-publish is true publishes the image) - - name: Get image tag - id: get-image-tag - run: | - short_sha=$(git rev-parse --short HEAD) - echo "build-publish=false" | tee -a $GITHUB_OUTPUT - if [[ ${{ github.event_name }} == 'push' ]]; then - if [[ ${{ github.ref_name }} == 'release/'* ]]; then - echo "image-tag=release-${short_sha}" | tee -a $GITHUB_OUTPUT - echo "build-publish=true" | tee -a $GITHUB_OUTPUT - else - echo "image-tag=develop" | tee -a $GITHUB_OUTPUT - echo "build-publish=true" | tee -a $GITHUB_OUTPUT - fi - elif [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then - echo "image-tag=${short_sha}" | tee -a $GITHUB_OUTPUT - echo "build-publish=${{ github.event.inputs.build-publish }}" | tee -a $GITHUB_OUTPUT - else - if [[ ${{ github.event_name }} == "pull_request" ]]; then - echo "image-tag=pr-${{ github.event.number }}-${short_sha}" | tee -a $GITHUB_OUTPUT - if [[ ${{ contains(github.event.pull_request.labels.*.name, 'build-publish') }} == "true" ]]; then - echo "build-publish=true" | tee -a $GITHUB_OUTPUT - fi - fi - fi - - name: Configure aws credentials - if: steps.get-image-tag.outputs.build-publish == 'true' uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 with: - role-to-assume: ${{ secrets.AWS_OIDC_IAM_ROLE_BUILD_PUBLISH_DEVELOP_PR }} + role-to-assume: ${{ secrets.AWS_OIDC_IAM_ROLE_PUBLISH_PR_ARN }} aws-region: ${{ secrets.AWS_REGION }} mask-aws-account-id: true - role-session-name: goreleaser-build-publish-${{ matrix.image-name }} + role-session-name: "merge" - - name: Build and publish images + - uses: actions/cache/restore@v4 + with: + path: dist/linux_amd64_v1 + key: chainlink-amd64-${{ github.sha }} + fail-on-cache-miss: true + + - uses: actions/cache/restore@v4 + with: + path: dist/linux_arm64 + key: chainlink-arm64-${{ github.sha }} + fail-on-cache-miss: true + + - name: Merge images for both architectures uses: ./.github/actions/goreleaser-build-sign-publish with: - enable-docker-publish: ${{ steps.get-image-tag.outputs.build-publish }} docker-registry: ${{ secrets.AWS_SDLC_ECR_HOSTNAME }} - docker-image-name: ${{ matrix.image-name }} - docker-image-tag: ${{ steps.get-image-tag.outputs.image-tag }} - enable-goreleaser-snapshot: "true" - goreleaser-exec: ./tools/bin/goreleaser_wrapper - goreleaser-config: ${{ matrix.goreleaser-config }} + docker-image-tag: ${{ needs.image-tag.outputs.image-tag }} + goreleaser-release-type: "merge" + goreleaser-config: .goreleaser.develop.yaml goreleaser-key: ${{ secrets.GORELEASER_KEY }} - zig-version: 0.11.0 - - name: Output image name and digest - if: steps.get-image-tag.outputs.build-publish == 'true' - shell: bash - run: | - echo "### Docker Images" | tee -a "$GITHUB_STEP_SUMMARY" - jq -r '.[] | select(.type == "Docker Image") | "\(.name)"' ${artifact_path} >> output.txt - while read -r line; do - echo "$line" | tee -a "$GITHUB_STEP_SUMMARY" - done < output.txt + split: + name: "split-${{ matrix.goarch }}" + needs: image-tag + runs-on: ${{ matrix.runner }} + permissions: + id-token: write + contents: read + strategy: + fail-fast: false + matrix: + include: + - runner: ubuntu-latest + goarch: amd64 + dist_name: linux_amd64_v1 + + - runner: ubuntu-24.04-4cores-16GB-ARM + goarch: arm64 + dist_name: linux_arm64 + steps: + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + with: + ref: ${{ env.GIT_REF }} + fetch-depth: 0 + + - name: Configure aws credentials + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 + with: + role-to-assume: ${{ secrets.AWS_OIDC_IAM_ROLE_PUBLISH_PR_ARN }} + aws-region: ${{ secrets.AWS_REGION }} + mask-aws-account-id: true + role-session-name: "split-${{ matrix.goarch }}" + + - id: cache + uses: actions/cache@v4 + with: + path: dist/${{ matrix.dist_name }} + key: chainlink-${{ matrix.goarch }}-${{ github.sha }} + + - name: Build images for ${{ matrix.goarch }} + uses: ./.github/actions/goreleaser-build-sign-publish + if: steps.cache.outputs.cache-hit != 'true' + with: + docker-registry: ${{ secrets.AWS_SDLC_ECR_HOSTNAME }} + docker-image-tag: ${{ needs.image-tag.outputs.image-tag }} + goreleaser-release-type: ${{ needs.image-tag.outputs.release-type }} + goreleaser-config: .goreleaser.develop.yaml + goreleaser-key: ${{ secrets.GORELEASER_KEY }} - name: Collect Metrics if: always() @@ -111,5 +128,40 @@ jobs: org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} - this-job-name: goreleaser-build-publish-${{ matrix.image-name }} - continue-on-error: true \ No newline at end of file + this-job-name: "split-${{ matrix.goarch }}" + continue-on-error: true + + image-tag: + runs-on: ubuntu-latest + outputs: + image-tag: ${{ steps.get-image-tag.outputs.image-tag }} + release-type: ${{ steps.get-image-tag.outputs.release-type }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: ${{ env.GIT_REF }} + + - name: Get image tag + id: get-image-tag + run: | + short_sha=$(git rev-parse --short HEAD) + echo "release-type=snapshot" | tee -a $GITHUB_OUTPUT + if [[ ${{ github.event_name }} == 'push' ]]; then + echo "image-tag=develop" | tee -a $GITHUB_OUTPUT + echo "release-type=nightly" | tee -a $GITHUB_OUTPUT + elif [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then + echo "image-tag=${short_sha}" | tee -a $GITHUB_OUTPUT + if [[ "${{ inputs.build-publish }}" == 'false' ]]; then + echo "release-type=snapshot" | tee -a $GITHUB_OUTPUT + else + echo "release-type=nightly" | tee -a $GITHUB_OUTPUT + fi + else + if [[ ${{ github.event_name }} == "pull_request" ]]; then + echo "image-tag=pr-${{ github.event.number }}-${short_sha}" | tee -a $GITHUB_OUTPUT + if [[ ${{ contains(github.event.pull_request.labels.*.name, 'build-publish') }} == "true" ]]; then + echo "release-type=nightly" | tee -a $GITHUB_OUTPUT + fi + fi + fi diff --git a/.github/workflows/build-publish-goreleaser.yml b/.github/workflows/build-publish-goreleaser.yml new file mode 100644 index 0000000000..f19df8cb0b --- /dev/null +++ b/.github/workflows/build-publish-goreleaser.yml @@ -0,0 +1,150 @@ +name: "Goreleaser Chainlink" + +on: + push: + tags: + - "goreleaser-v*" + +env: + ECR_HOSTNAME: public.ecr.aws + +jobs: + checks: + name: "Checks" + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + - name: Check for VERSION file bump on tags + # Avoids checking VERSION file bump on forks. + if: ${{ github.repository == 'smartcontractkit/chainlink' }} + uses: ./.github/actions/version-file-bump + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + # The main differences between this workflow and the develop one are: + # - Goreleaser pipeline only runs on tags + # - We only build ccip OR chainlink, not both + goreleaser-merge: + needs: [goreleaser-split] + name: merge + runs-on: ubuntu-latest + environment: build-publish + permissions: + id-token: write + contents: read + attestations: write + steps: + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + with: + fetch-depth: 0 + + - name: Configure aws credentials + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 + with: + role-to-assume: ${{ secrets.AWS_OIDC_IAM_ROLE_ARN }} + role-duration-seconds: ${{ secrets.AWS_ROLE_DURATION_SECONDS }} + aws-region: ${{ secrets.AWS_REGION }} + mask-aws-account-id: true + role-session-name: goreleaser-build-sign-publish-chainlink + + - uses: actions/cache/restore@v4 + with: + path: dist/linux_amd64_v1 + # We use ref_name here and not in develop b/c develop builds both ccip and chainlink + # whereas here we only build one or the other + key: chainlink-amd64-${{ github.sha }}-${{ github.ref_name }} + fail-on-cache-miss: true + + - uses: actions/cache/restore@v4 + with: + path: dist/linux_arm64 + key: chainlink-arm64-${{ github.sha }}-${{ github.ref_name }} + fail-on-cache-miss: true + + - name: Merge images for both architectures + id: goreleaser-build-sign-publish + uses: ./.github/actions/goreleaser-build-sign-publish + with: + docker-registry: ${{ env.ECR_HOSTNAME }} + docker-image-tag: ${{ github.ref_name }} + goreleaser-config: .goreleaser.production.yaml + goreleaser-release-type: merge + goreleaser-key: ${{ secrets.GORELEASER_KEY }} + + - name: Collect Metrics + if: always() + id: collect-gha-metrics + uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1 + with: + id: goreleaser-build-chainlink-publish + org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} + basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} + hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} + this-job-name: merge + continue-on-error: true + + goreleaser-split: + name: "split-${{ matrix.goarch }}" + needs: [checks] + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + include: + - runner: ubuntu-latest + goarch: amd64 + dist_name: linux_amd64_v1 + + - runner: ubuntu-24.04-4cores-16GB-ARM + goarch: arm64 + dist_name: linux_arm64 + environment: build-publish + permissions: + id-token: write + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 + with: + fetch-depth: 0 + + - name: Configure aws credentials + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 + with: + role-to-assume: ${{ secrets.AWS_OIDC_IAM_ROLE_ARN }} + role-duration-seconds: ${{ secrets.AWS_ROLE_DURATION_SECONDS }} + aws-region: ${{ secrets.AWS_REGION }} + mask-aws-account-id: true + role-session-name: goreleaser-build-sign-publish-chainlink + + - id: cache + uses: actions/cache@v4 + with: + path: dist/${{ matrix.dist_name }} + # We use ref_name here and not in develop b/c develop builds both ccip and chainlink + # whereas here we only build one or the other + key: chainlink-${{ matrix.goarch }}-${{ github.sha }}-${{ github.ref_name }} + + - name: Build images for ${{ matrix.goarch }} + if: steps.cache.outputs.cache-hit != 'true' + uses: ./.github/actions/goreleaser-build-sign-publish + with: + docker-registry: ${{ env.ECR_HOSTNAME }} + docker-image-tag: ${{ github.ref_name }} + goreleaser-release-type: release + goreleaser-config: .goreleaser.production.yaml + goreleaser-key: ${{ secrets.GORELEASER_KEY }} + + - name: Collect Metrics + if: always() + id: collect-gha-metrics + uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1 + with: + id: goreleaser-build-chainlink-publish + org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} + basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} + hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} + this-job-name: split-${{ matrix.goarch }} + continue-on-error: true diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 2902433f9d..59f0ddc907 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -1,12 +1,9 @@ name: "Build, Sign and Publish Chainlink" on: - # Mimics old circleci behaviour push: tags: - "v*" - branches: - - "release/**" env: ECR_HOSTNAME: public.ecr.aws @@ -21,14 +18,13 @@ jobs: uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - name: Check for VERSION file bump on tags # Avoids checking VERSION file bump on forks. - if: ${{ github.repository == 'smartcontractkit/chainlink' && startsWith(github.ref, 'refs/tags/v') }} + if: ${{ github.repository == 'smartcontractkit/chainlink' }} uses: ./.github/actions/version-file-bump with: github-token: ${{ secrets.GITHUB_TOKEN }} build-sign-publish-chainlink: needs: [checks] - if: ${{ ! startsWith(github.ref_name, 'release/') }} runs-on: ubuntu-20.04 environment: build-publish permissions: @@ -76,139 +72,6 @@ jobs: this-job-name: build-sign-publish-chainlink continue-on-error: true - goreleaser-build-sign-publish-chainlink: - needs: [checks] - if: ${{ ! startsWith(github.ref_name, 'release/') }} - runs-on: ubuntu-20.04 - environment: build-publish - permissions: - id-token: write - contents: write - attestations: write - steps: - - name: Checkout repository - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 - - - name: Configure aws credentials - uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2 - with: - role-to-assume: ${{ secrets.AWS_OIDC_IAM_ROLE_ARN }} - role-duration-seconds: ${{ secrets.AWS_ROLE_DURATION_SECONDS }} - aws-region: ${{ secrets.AWS_REGION }} - mask-aws-account-id: true - role-session-name: goreleaser-build-sign-publish-chainlink - - - name: Set build configs - shell: bash - id: set-build-configs - run: | - if [[ ${{ github.ref_name }} =~ "-ccip" ]]; then - echo "ECR_IMAGE_NAME=chainlink/ccip" | tee -a $GITHUB_OUTPUT - echo "GORELEASER_CONFIG=.goreleaser.ccip.production.yaml" | tee -a $GITHUB_OUTPUT - else - echo "ECR_IMAGE_NAME=chainlink/chainlink" | tee -a $GITHUB_OUTPUT - echo "GORELEASER_CONFIG=.goreleaser.production.yaml" | tee -a $GITHUB_OUTPUT - fi - - - name: Build, sign, and publish image - id: goreleaser-build-sign-publish - uses: ./.github/actions/goreleaser-build-sign-publish - with: - docker-registry: ${{ env.ECR_HOSTNAME}} - docker-image-name: ${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }} - docker-image-tag: ${{ github.ref_name }} - goreleaser-exec: ./tools/bin/goreleaser_wrapper - goreleaser-config: ${{ steps.set-build-configs.outputs.GORELEASER_CONFIG }} - goreleaser-key: ${{ secrets.GORELEASER_KEY }} - zig-version: 0.11.0 - enable-cosign: true - cosign-version: "v2.4.0" - - - name: Output image name and digest - id: get-image-name-digest - shell: bash - run: | - artifact_path="dist/artifacts.json" - jq -r '.[] | select(.type == "Docker Image") | "\(.name)"' ${artifact_path} >> output.txt - - echo "### Docker Images" | tee -a "$GITHUB_STEP_SUMMARY" - while read -r line; do - echo "$line" | tee -a "$GITHUB_STEP_SUMMARY" - done < output.txt - - core_amd64_name="${{ env.ECR_HOSTNAME }}/${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }}:${{ github.ref_name }}-amd64" - plugins_amd64_name="${{ env.ECR_HOSTNAME }}/${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }}:${{ github.ref_name }}-plugins-amd64" - core_arm64_name="${{ env.ECR_HOSTNAME }}/${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }}:${{ github.ref_name }}-arm64" - plugins_arm64_name="${{ env.ECR_HOSTNAME }}/${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }}:${{ github.ref_name }}-plugins-arm64" - - echo "core_amd64_digest=$(jq -r --arg name "$core_amd64_name" '.[]|select(.type=="Published Docker Image" and .name==$name)|.extra.Digest' ${artifact_path})" | tee -a "$GITHUB_OUTPUT" "$GITHUB_STEP_SUMMARY" - echo "plugins_amd64_digest=$(jq -r --arg name "$plugins_amd64_name" '.[]|select(.type=="Published Docker Image" and .name==$name)|.extra.Digest' ${artifact_path})" | tee -a "$GITHUB_OUTPUT" "$GITHUB_STEP_SUMMARY" - echo "core_arm64_digest=$(jq -r --arg name "$core_amd64_name" '.[]|select(.type=="Published Docker Image" and .name==$name)|.extra.Digest' ${artifact_path})" | tee -a "$GITHUB_OUTPUT" "$GITHUB_STEP_SUMMARY" - echo "plugins_arm64_digest=$(jq -r --arg name "$plugins_amd64_name" '.[]|select(.type=="Published Docker Image" and .name==$name)|.extra.Digest' ${artifact_path})" | tee -a "$GITHUB_OUTPUT" "$GITHUB_STEP_SUMMARY" - - - name: Attest tarballs - uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2 - with: - subject-path: "dist/*.tar.gz" - - - name: Attest Docker image (core-amd64) - uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2 - with: - subject-digest: ${{ steps.get-image-name-digest.outputs.core_amd64_digest }} - subject-name: ${{ env.ECR_HOSTNAME }}/${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }} - push-to-registry: true - - - name: Attest Docker image (plugins-amd64) - uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2 - with: - subject-digest: ${{ steps.get-image-name-digest.outputs.plugins_amd64_digest }} - subject-name: ${{ env.ECR_HOSTNAME }}/${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }} - push-to-registry: true - - - name: Attest Docker image (core-arm64) - uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2 - with: - subject-digest: ${{ steps.get-image-name-digest.outputs.core_arm64_digest }} - subject-name: ${{ env.ECR_HOSTNAME }}/${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }} - push-to-registry: true - - - name: Attest Docker image (plugins-arm64) - uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2 - with: - subject-digest: ${{ steps.get-image-name-digest.outputs.plugins_arm64_digest }} - subject-name: ${{ env.ECR_HOSTNAME }}/${{ steps.set-build-configs.outputs.ECR_IMAGE_NAME }} - push-to-registry: true - - - name: Upload SBOMs - uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4 - with: - name: goreleaser-sboms - path: dist/*.sbom.json - - - name: Print SBOM artifact to job summary - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - shell: bash - run: | - ARTIFACTS=$(gh api -X GET repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts) - ARTIFACT_ID=$(echo "$ARTIFACTS" | jq '.artifacts[] | select(.name=="goreleaser-sboms") | .id') - echo "Artifact ID: $ARTIFACT_ID" - echo "### SBOM Artifact" | tee -a "$GITHUB_STEP_SUMMARY" - artifact_url="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/$ARTIFACT_ID" - echo "[Artifact URL]($artifact_url)" | tee -a $GITHUB_STEP_SUMMARY - - - name: Collect Metrics - if: always() - id: collect-gha-metrics - uses: smartcontractkit/push-gha-metrics-action@d9da21a2747016b3e13de58c7d4115a3d5c97935 # v3.0.1 - with: - id: goreleaser-build-chainlink-publish - org-id: ${{ secrets.GRAFANA_INTERNAL_TENANT_ID }} - basic-auth: ${{ secrets.GRAFANA_INTERNAL_BASIC_AUTH }} - hostname: ${{ secrets.GRAFANA_INTERNAL_HOST }} - this-job-name: goreleaser-build-sign-publish-chainlink - continue-on-error: true - # Notify Slack channel for new git tags. slack-notify: if: github.ref_type == 'tag' diff --git a/.goreleaser.ccip.develop.yaml b/.goreleaser.ccip.develop.yaml deleted file mode 100644 index 595fe14c27..0000000000 --- a/.goreleaser.ccip.develop.yaml +++ /dev/null @@ -1,229 +0,0 @@ -project_name: chainlink - -version: 2 - -env: - - ZIG_EXEC={{ if index .Env "ZIG_EXEC" }}{{ .Env.ZIG_EXEC }}{{ else }}zig{{ end }} - - IMAGE_PREFIX={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }} - - IMAGE_NAME={{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else }}chainlink{{ end }} - - IMAGE_TAG={{ if index .Env "IMAGE_TAG" }}{{ .Env.IMAGE_TAG }}{{ else }}develop{{ 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: - - binary: chainlink - id: linux-arm64 - goos: - - linux - goarch: - - arm64 - hooks: - post: ./tools/bin/goreleaser_utils build_post_hook {{ dir .Path }} {{ .Os }} {{ .Arch }} - env: - - CGO_ENABLED=1 - - CC=$ZIG_EXEC cc -target aarch64-linux-gnu - - CCX=$ZIG_EXEC c++ -target aarch64-linux-gnu - flags: - - -trimpath - - -buildmode=pie - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.CHAINLINK_VERSION }} - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - - 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 - - CCX=$ZIG_EXEC c++ -target x86_64-linux-gnu - flags: - - -trimpath - - -buildmode=pie - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.CHAINLINK_VERSION }} - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - -# See https://goreleaser.com/customization/docker/ -dockers: - - id: linux-amd64 - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: amd64 - extra_files: - - tmp/linux_amd64/libs - - tools/bin/ldd_fix - - ccip/config - build_flag_templates: - - "--platform=linux/amd64" - - "--pull" - - "--build-arg=CHAINLINK_USER=chainlink" - - "--build-arg=COMMIT_SHA={{ .FullCommit }}" - - "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-amd64" - - id: linux-arm64 - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: arm64 - extra_files: - - tmp/linux_arm64/libs - - tools/bin/ldd_fix - - ccip/config - build_flag_templates: - - "--platform=linux/arm64" - - "--pull" - - "--build-arg=CHAINLINK_USER=chainlink" - - "--build-arg=COMMIT_SHA={{ .FullCommit }}" - - "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-arm64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-arm64" - - id: linux-amd64-plugins - 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 - - ccip/config - 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" - - "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-amd64" - - id: linux-arm64-plugins - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: arm64 - extra_files: - - tmp/linux_arm64/libs - - tmp/linux_arm64/plugins - - tools/bin/ldd_fix - - ccip/config - 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" - - "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-arm64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-arm64" - -# See https://goreleaser.com/customization/docker_manifest/ -docker_manifests: - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-arm64" - -# See https://goreleaser.com/customization/docker_sign/ -docker_signs: - - artifacts: all - args: - - "sign" - - "${artifact}" - - "--yes" - -checksum: - name_template: "checksums.txt" - -snapshot: - version_template: "{{ .Env.CHAINLINK_VERSION }}-{{ .ShortCommit }}" - -partial: - by: target - -# See https://goreleaser.com/customization/release/ -release: - disable: true - -changelog: - 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.ccip.production.yaml b/.goreleaser.ccip.production.yaml deleted file mode 100644 index 1247be143c..0000000000 --- a/.goreleaser.ccip.production.yaml +++ /dev/null @@ -1,229 +0,0 @@ -project_name: chainlink - -version: 2 - -env: - - ZIG_EXEC={{ if index .Env "ZIG_EXEC" }}{{ .Env.ZIG_EXEC }}{{ else }}zig{{ end }} - - IMAGE_PREFIX={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }} - - IMAGE_NAME={{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else }}chainlink{{ end }} - - IMAGE_TAG={{ if index .Env "IMAGE_TAG" }}{{ .Env.IMAGE_TAG }}{{ else }}develop{{ 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: - - binary: chainlink - id: linux-arm64 - goos: - - linux - goarch: - - arm64 - hooks: - post: ./tools/bin/goreleaser_utils build_post_hook {{ dir .Path }} {{ .Os }} {{ .Arch }} - env: - - CGO_ENABLED=1 - - CC=$ZIG_EXEC cc -target aarch64-linux-gnu - - CCX=$ZIG_EXEC c++ -target aarch64-linux-gnu - flags: - - -trimpath - - -buildmode=pie - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.CHAINLINK_VERSION }} - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - - 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 - - CCX=$ZIG_EXEC c++ -target x86_64-linux-gnu - flags: - - -trimpath - - -buildmode=pie - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.CHAINLINK_VERSION }} - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - -# See https://goreleaser.com/customization/docker/ -dockers: - - id: linux-amd64 - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: amd64 - extra_files: - - tmp/linux_amd64/libs - - tools/bin/ldd_fix - - ccip/config - build_flag_templates: - - "--platform=linux/amd64" - - "--pull" - - "--build-arg=CHAINLINK_USER=chainlink" - - "--build-arg=COMMIT_SHA={{ .FullCommit }}" - - "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-amd64" - - id: linux-arm64 - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: arm64 - extra_files: - - tmp/linux_arm64/libs - - tools/bin/ldd_fix - - ccip/config - build_flag_templates: - - "--platform=linux/arm64" - - "--pull" - - "--build-arg=CHAINLINK_USER=chainlink" - - "--build-arg=COMMIT_SHA={{ .FullCommit }}" - - "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-arm64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-arm64" - - id: linux-amd64-plugins - 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 - - ccip/config - 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" - - "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-amd64" - - id: linux-arm64-plugins - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: arm64 - extra_files: - - tmp/linux_arm64/libs - - tmp/linux_arm64/plugins - - tools/bin/ldd_fix - - ccip/config - 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" - - "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-arm64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-arm64" - -# See https://goreleaser.com/customization/docker_manifest/ -docker_manifests: - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-arm64" - -# See https://goreleaser.com/customization/docker_sign/ -docker_signs: - - artifacts: all - args: - - "sign" - - "${artifact}" - - "--yes" - -checksum: - name_template: "checksums.txt" - -# See https://goreleaser.com/customization/sbom -sboms: - - artifacts: archive - -snapshot: - version_template: "{{ .Env.CHAINLINK_VERSION }}-{{ .ShortCommit }}" - -partial: - by: target - -# See https://goreleaser.com/customization/release/ -release: - disable: true - -changelog: - 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.develop.yaml b/.goreleaser.develop.yaml index f8757676f8..083233e3e7 100644 --- a/.goreleaser.develop.yaml +++ b/.goreleaser.develop.yaml @@ -1,221 +1,207 @@ -project_name: chainlink - version: 2 - +project_name: ccip env: - - ZIG_EXEC={{ if index .Env "ZIG_EXEC" }}{{ .Env.ZIG_EXEC }}{{ else }}zig{{ end }} - - IMAGE_PREFIX={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }} - - IMAGE_NAME={{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else }}chainlink{{ end }} - - IMAGE_TAG={{ if index .Env "IMAGE_TAG" }}{{ .Env.IMAGE_TAG }}{{ else }}develop{{ 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/ + - 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" builds: - - binary: chainlink - id: linux-arm64 - goos: - - linux - goarch: - - arm64 - hooks: - post: ./tools/bin/goreleaser_utils build_post_hook {{ dir .Path }} {{ .Os }} {{ .Arch }} - env: - - CGO_ENABLED=1 - - CC=$ZIG_EXEC cc -target aarch64-linux-gnu - - CCX=$ZIG_EXEC c++ -target aarch64-linux-gnu - flags: - - -trimpath - - -buildmode=pie - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.CHAINLINK_VERSION }} - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - - 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 - - CCX=$ZIG_EXEC c++ -target x86_64-linux-gnu - flags: - - -trimpath - - -buildmode=pie - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.CHAINLINK_VERSION }} - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - -# See https://goreleaser.com/customization/docker/ + - 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={{ if contains .Runtime.Goarch "amd64" -}} + /lib64/ld-linux-x86-64.so.2 + {{- else if contains .Runtime.Goarch "arm64" -}} + /lib/ld-linux-aarch64.so.1 + {{- end }}" + - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.VERSION }} + flags: + - -trimpath + - -buildmode=pie +archives: + - format: binary +snapshot: + version_template: '{{ .Env.VERSION }}-{{ .ShortCommit }}' +checksum: + name_template: checksums.txt dockers: - - id: linux-amd64 - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: amd64 - extra_files: - - tmp/linux_amd64/libs - - tools/bin/ldd_fix - build_flag_templates: - - "--platform=linux/amd64" - - "--pull" - - "--build-arg=CHAINLINK_USER=chainlink" - - "--build-arg=COMMIT_SHA={{ .FullCommit }}" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-amd64" - - id: linux-arm64 - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: arm64 - extra_files: - - tmp/linux_arm64/libs - - tools/bin/ldd_fix - build_flag_templates: - - "--platform=linux/arm64" - - "--pull" - - "--build-arg=CHAINLINK_USER=chainlink" - - "--build-arg=COMMIT_SHA={{ .FullCommit }}" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-arm64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-arm64" - - id: linux-amd64-plugins - 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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-amd64" - - id: linux-arm64-plugins - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: arm64 - extra_files: - - tmp/linux_arm64/libs - - tmp/linux_arm64/plugins - - tools/bin/ldd_fix - 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={{ .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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-arm64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-arm64" - -# See https://goreleaser.com/customization/docker_manifest/ + - id: linux-amd64-ccip + goos: linux + goarch: amd64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/ccip:{{ .Env.IMG_TAG }}' + - '{{ .Env.IMG_PRE }}/ccip:{{ .Env.IMG_TAG }}-amd64' + - '{{ .Env.IMG_PRE }}/ccip:sha-{{ .ShortCommit }}-amd64' + extra_files: + - tmp/libs + - ccip/config + build_flag_templates: + - --platform=linux/amd64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-amd64-ccip-plugins + goos: linux + goarch: amd64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/ccip:{{ .Env.IMG_TAG }}-plugins' + - '{{ .Env.IMG_PRE }}/ccip:{{ .Env.IMG_TAG }}-plugins-amd64' + - '{{ .Env.IMG_PRE }}/ccip:sha-{{ .ShortCommit }}-plugins-amd64' + extra_files: + - tmp/libs + - tmp/plugins + - ccip/config + build_flag_templates: + - --platform=linux/amd64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-arm64-ccip + goos: linux + goarch: arm64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/ccip:{{ .Env.IMG_TAG }}-arm64' + - '{{ .Env.IMG_PRE }}/ccip:sha-{{ .ShortCommit }}-arm64' + extra_files: + - tmp/libs + - ccip/config + build_flag_templates: + - --platform=linux/arm64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-arm64-ccip-plugins + goos: linux + goarch: arm64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/ccip:{{ .Env.IMG_TAG }}-plugins-arm64' + - '{{ .Env.IMG_PRE }}/ccip:sha-{{ .ShortCommit }}-plugins-arm64' + extra_files: + - tmp/libs + - tmp/plugins + - ccip/config + build_flag_templates: + - --platform=linux/arm64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx docker_manifests: - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-arm64" - -# See https://goreleaser.com/customization/docker_sign/ -docker_signs: - - artifacts: all - args: - - "sign" - - "${artifact}" - - "--yes" - -checksum: - name_template: "checksums.txt" - -snapshot: - version_template: "{{ .Env.CHAINLINK_VERSION }}-{{ .ShortCommit }}" - -partial: - by: target - -# See https://goreleaser.com/customization/release/ -release: - disable: true - + - id: tagged-chainlink + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink:{{ .Env.IMG_TAG }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink:{{ .Env.IMG_TAG }}' + - '{{ .Env.IMAGE_PREFIX }}/chainlink:{{ .Env.IMG_TAG }}-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink:{{ .Env.IMG_TAG }}-arm64' + - id: sha-chainlink + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink:sha-{{ .ShortCommit }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink:sha-{{ .ShortCommit }}-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink:sha-{{ .ShortCommit }}-arm64' + - id: tagged-plugins-chainlink + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink:{{ .Env.IMG_TAG }}-plugins' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink:{{ .Env.IMG_TAG }}-plugins' + - '{{ .Env.IMAGE_PREFIX }}/chainlink:{{ .Env.IMG_TAG }}-plugins-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink:{{ .Env.IMG_TAG }}-plugins-arm64' + - id: sha-plugins-chainlink + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink:sha-{{ .ShortCommit }}-plugins' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink:sha-{{ .ShortCommit }}-plugins-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink:sha-{{ .ShortCommit }}-plugins-arm64' + - id: tagged-ccip + name_template: '{{ .Env.IMAGE_PREFIX }}/ccip:{{ .Env.IMG_TAG }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/ccip:{{ .Env.IMG_TAG }}' + - '{{ .Env.IMAGE_PREFIX }}/ccip:{{ .Env.IMG_TAG }}-amd64' + - '{{ .Env.IMAGE_PREFIX }}/ccip:{{ .Env.IMG_TAG }}-arm64' + - id: sha-ccip + name_template: '{{ .Env.IMAGE_PREFIX }}/ccip:sha-{{ .ShortCommit }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/ccip:sha-{{ .ShortCommit }}-amd64' + - '{{ .Env.IMAGE_PREFIX }}/ccip:sha-{{ .ShortCommit }}-arm64' + - id: tagged-plugins-ccip + name_template: '{{ .Env.IMAGE_PREFIX }}/ccip:{{ .Env.IMG_TAG }}-plugins' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/ccip:{{ .Env.IMG_TAG }}-plugins' + - '{{ .Env.IMAGE_PREFIX }}/ccip:{{ .Env.IMG_TAG }}-plugins-amd64' + - '{{ .Env.IMAGE_PREFIX }}/ccip:{{ .Env.IMG_TAG }}-plugins-arm64' + - id: sha-plugins-ccip + name_template: '{{ .Env.IMAGE_PREFIX }}/ccip:sha-{{ .ShortCommit }}-plugins' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/ccip:sha-{{ .ShortCommit }}-plugins-amd64' + - '{{ .Env.IMAGE_PREFIX }}/ccip:sha-{{ .ShortCommit }}-plugins-arm64' changelog: - 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 + disable: "true" +before: + hooks: + - cmd: go mod tidy + - cmd: ./tools/bin/goreleaser_utils before_hook +git: + ignore_tags: + - contracts-ccip/v1.5.0-beta.0 +partial: + by: target +nightly: + version_template: '{{ .Env.VERSION }}-{{ .Env.IMG_TAG }}' diff --git a/.goreleaser.devspace.yaml b/.goreleaser.devspace.yaml index ccea1de96b..244440a2af 100644 --- a/.goreleaser.devspace.yaml +++ b/.goreleaser.devspace.yaml @@ -1,96 +1,105 @@ -## goreleaser <1.14.0 -project_name: ccip - version: 2 - +project_name: ccip env: - - 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/ + - 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" builds: - - 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/ + - 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={{ if contains .Runtime.Goarch "amd64" -}} + /lib64/ld-linux-x86-64.so.2 + {{- else if contains .Runtime.Goarch "arm64" -}} + /lib/ld-linux-aarch64.so.1 + {{- end }}" + - -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 dockers: - - 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/ + - 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 docker_manifests: - - 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" }}' - + - name_template: '{{ .Env.IMAGE }}' + image_templates: + - '{{ .Env.IMAGE }}' changelog: - sort: asc - filters: - exclude: - - "^docs:" - - "^test:" - -# See https://goreleaser.com/customization/git/ + disable: "true" +before: + hooks: + - cmd: go mod tidy + - cmd: ./tools/bin/goreleaser_utils before_hook git: - ignore_tags: - - contracts-ccip/v1.5.0-beta.0 - -# 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 + ignore_tags: + - contracts-ccip/v1.5.0-beta.0 +partial: + by: target +nightly: + version_template: v0.0.0-{{ .Runtime.Goarch }}-{{ .Now.Format "2006-01-02-15-04-05Z" }} diff --git a/.goreleaser.production.yaml b/.goreleaser.production.yaml index 0274f1322b..b4e19d1b31 100644 --- a/.goreleaser.production.yaml +++ b/.goreleaser.production.yaml @@ -1,221 +1,330 @@ -project_name: chainlink - version: 2 - +project_name: chainlink env: - - ZIG_EXEC={{ if index .Env "ZIG_EXEC" }}{{ .Env.ZIG_EXEC }}{{ else }}zig{{ end }} - - IMAGE_PREFIX={{ if index .Env "IMAGE_PREFIX" }}{{ .Env.IMAGE_PREFIX }}{{ else }}localhost:5001{{ end }} - - IMAGE_NAME={{ if index .Env "IMAGE_NAME" }}{{ .Env.IMAGE_NAME }}{{ else }}chainlink{{ end }} - - IMAGE_TAG={{ if index .Env "IMAGE_TAG" }}{{ .Env.IMAGE_TAG }}{{ else }}develop{{ 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/ + - 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" builds: - - binary: chainlink - id: linux-arm64 - goos: - - linux - goarch: - - arm64 - hooks: - post: ./tools/bin/goreleaser_utils build_post_hook {{ dir .Path }} {{ .Os }} {{ .Arch }} - env: - - CGO_ENABLED=1 - - CC=$ZIG_EXEC cc -target aarch64-linux-gnu - - CCX=$ZIG_EXEC c++ -target aarch64-linux-gnu - flags: - - -trimpath - - -buildmode=pie - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.CHAINLINK_VERSION }} - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - - 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 - - CCX=$ZIG_EXEC c++ -target x86_64-linux-gnu - flags: - - -trimpath - - -buildmode=pie - ldflags: - - -s -w -r=$ORIGIN/libs - - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.CHAINLINK_VERSION }} - - -X github.com/smartcontractkit/chainlink/v2/core/static.Sha={{ .FullCommit }} - -# See https://goreleaser.com/customization/docker/ + - 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={{ if contains .Runtime.Goarch "amd64" -}} + /lib64/ld-linux-x86-64.so.2 + {{- else if contains .Runtime.Goarch "arm64" -}} + /lib/ld-linux-aarch64.so.1 + {{- end }}" + - -X github.com/smartcontractkit/chainlink/v2/core/static.Version={{ .Env.VERSION }} + flags: + - -trimpath + - -buildmode=pie +archives: + - format: tar.gz +snapshot: + version_template: '{{ .Env.VERSION }}-{{ .ShortCommit }}' +checksum: + name_template: checksums.txt dockers: - - id: linux-amd64 - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: amd64 - extra_files: - - tmp/linux_amd64/libs - - tools/bin/ldd_fix - build_flag_templates: - - "--platform=linux/amd64" - - "--pull" - - "--build-arg=CHAINLINK_USER=chainlink" - - "--build-arg=COMMIT_SHA={{ .FullCommit }}" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-amd64" - - id: linux-arm64 - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: arm64 - extra_files: - - tmp/linux_arm64/libs - - tools/bin/ldd_fix - build_flag_templates: - - "--platform=linux/arm64" - - "--pull" - - "--build-arg=CHAINLINK_USER=chainlink" - - "--build-arg=COMMIT_SHA={{ .FullCommit }}" - - "--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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-arm64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-arm64" - - id: linux-amd64-plugins - 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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-amd64" - - id: linux-arm64-plugins - dockerfile: core/chainlink.goreleaser.Dockerfile - use: buildx - goos: linux - goarch: arm64 - extra_files: - - tmp/linux_arm64/libs - - tmp/linux_arm64/plugins - - tools/bin/ldd_fix - 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={{ .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={{ .Env.CHAINLINK_VERSION }}" - - "--label=org.opencontainers.image.url={{ .Env.IMAGE_LABEL_SOURCE }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-arm64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-arm64" - -# See https://goreleaser.com/customization/docker_manifest/ + - id: linux-amd64-chainlink + goos: linux + goarch: amd64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-amd64' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-amd64' + skip_push: '{{ contains .Tag "-ccip" }}' + extra_files: + - tmp/libs + build_flag_templates: + - --platform=linux/amd64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-amd64-chainlink-plugins + goos: linux + goarch: amd64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins-amd64' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins-amd64' + skip_push: '{{ contains .Tag "-ccip" }}' + 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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-arm64-chainlink + goos: linux + goarch: arm64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-arm64' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-arm64' + skip_push: '{{ contains .Tag "-ccip" }}' + extra_files: + - tmp/libs + build_flag_templates: + - --platform=linux/arm64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-arm64-chainlink-plugins + goos: linux + goarch: arm64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins-arm64' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins-arm64' + skip_push: '{{ contains .Tag "-ccip" }}' + 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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-amd64-ccip + goos: linux + goarch: amd64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-amd64' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-amd64' + skip_push: '{{ not (contains .Tag "-ccip") }}' + extra_files: + - tmp/libs + - ccip/config + build_flag_templates: + - --platform=linux/amd64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-amd64-ccip-plugins + goos: linux + goarch: amd64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins-amd64' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins-amd64' + skip_push: '{{ not (contains .Tag "-ccip") }}' + extra_files: + - tmp/libs + - tmp/plugins + - ccip/config + build_flag_templates: + - --platform=linux/amd64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-arm64-ccip + goos: linux + goarch: arm64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-arm64' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-arm64' + skip_push: '{{ not (contains .Tag "-ccip") }}' + extra_files: + - tmp/libs + - ccip/config + build_flag_templates: + - --platform=linux/arm64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx + - id: linux-arm64-ccip-plugins + goos: linux + goarch: arm64 + dockerfile: core/chainlink.goreleaser.Dockerfile + image_templates: + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins-arm64' + - '{{ .Env.IMG_PRE }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins-arm64' + skip_push: '{{ not (contains .Tag "-ccip") }}' + extra_files: + - tmp/libs + - tmp/plugins + - ccip/config + build_flag_templates: + - --platform=linux/arm64 + - --pull + - --build-arg=CHAINLINK_USER=chainlink + - --build-arg=COMMIT_SHA={{ .FullCommit }} + - --build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config + - --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 + - --label=org.opencontainers.image.version={{ .Env.VERSION }} + use: buildx docker_manifests: - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:{{ .Env.IMAGE_TAG }}-plugins-arm64" - - name_template: "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins" - image_templates: - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-amd64" - - "{{ .Env.IMAGE_PREFIX }}/{{ .Env.IMAGE_NAME }}:sha-{{ .ShortCommit }}-plugins-arm64" - -# See https://goreleaser.com/customization/docker_sign/ -docker_signs: - - artifacts: all - args: - - "sign" - - "${artifact}" - - "--yes" - -checksum: - name_template: "checksums.txt" - -# See https://goreleaser.com/customization/sbom + - id: tagged-chainlink-chainlink-experimental-goreleaser + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}' + skip_push: '{{ contains .Tag "-ccip" }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-arm64' + - id: sha-chainlink-chainlink-experimental-goreleaser + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}' + skip_push: '{{ contains .Tag "-ccip" }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-arm64' + - id: tagged-plugins-chainlink-chainlink-experimental-goreleaser + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins' + skip_push: '{{ contains .Tag "-ccip" }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins-arm64' + - id: sha-plugins-chainlink-chainlink-experimental-goreleaser + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins' + skip_push: '{{ contains .Tag "-ccip" }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins-arm64' + - id: tagged-chainlink-chainlink-ccip-experimental-goreleaser + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}' + skip_push: '{{ not (contains .Tag "-ccip") }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-arm64' + - id: sha-chainlink-chainlink-ccip-experimental-goreleaser + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}' + skip_push: '{{ not (contains .Tag "-ccip") }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-arm64' + - id: tagged-plugins-chainlink-chainlink-ccip-experimental-goreleaser + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins' + skip_push: '{{ not (contains .Tag "-ccip") }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:{{ .Env.IMG_TAG }}-plugins-arm64' + - id: sha-plugins-chainlink-chainlink-ccip-experimental-goreleaser + name_template: '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins' + skip_push: '{{ not (contains .Tag "-ccip") }}' + image_templates: + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins-amd64' + - '{{ .Env.IMAGE_PREFIX }}/chainlink/chainlink-ccip-experimental-goreleaser:sha-{{ .ShortCommit }}-plugins-arm64' +changelog: + filters: + exclude: + - '^docs:' + - '^test:' + sort: asc +before: + hooks: + - cmd: go mod tidy + - cmd: ./tools/bin/goreleaser_utils before_hook sboms: - - artifacts: archive - -snapshot: - version_template: "{{ .Env.CHAINLINK_VERSION }}-{{ .ShortCommit }}" - + - artifacts: archive partial: - by: target - -# See https://goreleaser.com/customization/release/ -release: - disable: true - -changelog: - 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 + by: target +nightly: + version_template: '{{ .Env.VERSION }}-{{ .Env.IMG_TAG }}' diff --git a/.tool-versions b/.tool-versions index 12a86bb1c1..4265fb5f89 100644 --- a/.tool-versions +++ b/.tool-versions @@ -4,7 +4,6 @@ nodejs 20.13.1 pnpm 9.4.0 postgres 15.1 helm 3.10.3 -zig 0.11.0 golangci-lint 1.60.3 protoc 25.1 python 3.10.5 diff --git a/GNUmakefile b/GNUmakefile index 5f04d6c15e..42ab5cd8e1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -176,16 +176,6 @@ golangci-lint: ## Run golangci-lint for all issues. [ -d "./golangci-lint" ] || mkdir ./golangci-lint && \ docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.59.1 golangci-lint run --max-issues-per-linter 0 --max-same-issues 0 | tee ./golangci-lint/$(shell date +%Y-%m-%d_%H:%M:%S).txt -GORELEASER_CONFIG ?= .goreleaser.yaml - -.PHONY: goreleaser-dev-build -goreleaser-dev-build: ## Run goreleaser snapshot build - ./tools/bin/goreleaser_wrapper build --snapshot --rm-dist --config ${GORELEASER_CONFIG} - -.PHONY: goreleaser-dev-release -goreleaser-dev-release: ## run goreleaser snapshot release - ./tools/bin/goreleaser_wrapper release --snapshot --rm-dist --config ${GORELEASER_CONFIG} - .PHONY: modgraph modgraph: ./tools/bin/modgraph > go.md diff --git a/core/chainlink.goreleaser.Dockerfile b/core/chainlink.goreleaser.Dockerfile index c229ad488c..eb35937600 100644 --- a/core/chainlink.goreleaser.Dockerfile +++ b/core/chainlink.goreleaser.Dockerfile @@ -1,12 +1,12 @@ # This will replace chainlink.Dockerfile once all builds are migrated to goreleaser # Final image: ubuntu with chainlink binary -FROM ubuntu:20.04 +FROM ubuntu:24.04 ARG CHAINLINK_USER=root ARG TARGETARCH ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get install -y ca-certificates gnupg lsb-release curl patchelf +RUN apt-get update && apt-get install -y ca-certificates gnupg lsb-release curl # Install Postgres for CLI tools, needed specifically for DB backups RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ @@ -18,11 +18,12 @@ RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ COPY ./chainlink /usr/local/bin/ # Copy native libs if cgo is enabled -COPY ./tmp/linux_${TARGETARCH}/libs /usr/local/bin/libs +COPY ./tmp/libs /usr/local/bin/libs # Copy plugins if exist and enable them # https://stackoverflow.com/questions/70096208/dockerfile-copy-folder-if-it-exists-conditional-copy/70096420#70096420 -COPY ./tmp/linux_${TARGETARCH}/plugin[s] /usr/local/bin/ +COPY ./tm[p]/plugin[s]/ /usr/local/bin/ + # Allow individual plugins to be enabled by supplying their path ARG CL_MEDIAN_CMD ARG CL_MERCURY_CMD @@ -32,11 +33,6 @@ ENV CL_MEDIAN_CMD=${CL_MEDIAN_CMD} \ CL_MERCURY_CMD=${CL_MERCURY_CMD} \ CL_SOLANA_CMD=${CL_SOLANA_CMD} \ CL_STARKNET_CMD=${CL_STARKNET_CMD} -# Temp fix to patch correctly link the libwasmvm.so -COPY ./tools/bin/ldd_fix /usr/local/bin/ldd_fix -RUN chmod +x /usr/local/bin/ldd_fix -RUN /usr/local/bin/ldd_fix -RUN apt-get remove -y patchelf # CCIP specific COPY ./cci[p]/confi[g] /chainlink/ccip-config diff --git a/flake.lock b/flake.lock index 77dddea406..71af2318c9 100644 --- a/flake.lock +++ b/flake.lock @@ -40,6 +40,24 @@ "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, @@ -55,6 +73,22 @@ } }, "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=", @@ -70,11 +104,28 @@ "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", - "nixpkgs": "nixpkgs_2" + "goreleaser-nur": "goreleaser-nur", + "nixpkgs": "nixpkgs_3", + "nur": "nur" } }, "systems": { diff --git a/flake.nix b/flake.nix index 7e188857ba..0d1aac2f05 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,8 @@ 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 @ { @@ -13,15 +15,30 @@ nixpkgs, flake-utils, foundry, + nur, + goreleaser-nur, ... }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [foundry.overlay]; - }; + 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 + ]; + }; 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 new file mode 100755 index 0000000000..49dbfc6098 --- /dev/null +++ b/nix-darwin-shell-hook.sh @@ -0,0 +1,30 @@ +#!/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 3626cb11cf..e3b187dcd9 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,4 @@ -{pkgs}: +{pkgs, isCrib}: with pkgs; let go = go_1_21; postgresql = postgresql_14; @@ -18,7 +18,6 @@ in nativeBuildInputs = [ go - goreleaser postgresql python3 @@ -44,9 +43,6 @@ in github-cli jq - # cross-compiling, used in CRIB - zig - # gofuzz ] ++ lib.optionals stdenv.isLinux [ @@ -54,10 +50,22 @@ in pkg-config libudev-zero libusb1 + ] ++ lib.optionals isCrib [ + nur.repos.goreleaser.goreleaser-pro + patchelf ]; - LD_LIBRARY_PATH = "${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH"; - GOROOT = "${go}/share/go"; + 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 ""} + ''} + ''; + + 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 979204d1e3..b4b7f124ba 100755 --- a/tools/bin/goreleaser_utils +++ b/tools/bin/goreleaser_utils @@ -1,90 +1,55 @@ #!/usr/bin/env bash set -xe +# global goreleaser before hook +# moves native libraries to temp directories used by docker images / archives +before_hook() { + local -r lib_path=tmp -# get machine / kernel name -_get_platform() { - uname | tr '[:upper:]' '[:lower:]' -} - -# get machine architecture name -# See https://github.com/joschi/asdf-java/blob/aarch64-support/bin/functions#L33 -_get_arch() { - arch="$(uname -m)" - case "${arch}" in - x86_64 | amd64) echo "x86_64" ;; - aarch64 | arm64) echo "arm64" ;; - *) - echo "Unknown machine architecture: ${arch}" - exit 1 - ;; - esac -} + mkdir -p "$lib_path/libs" + # Copy over all platform versions of the wasmvm library + cp -f "$(go list -json -m github.com/CosmWasm/wasmvm | jq -r '.Dir')"/internal/api/libwasmvm.* "$lib_path/libs" + + 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 -# get lib wasmvm path -_get_wasmvm_lib_path() { - local -r platform="$1" - local -r arch="$2" - wasmvm_dir=$(go list -json -m github.com/CosmWasm/wasmvm | jq -r '.Dir') - shared_lib_dir="$wasmvm_dir/internal/api" - lib_name="libwasmvm" - if [ "$platform" == "darwin" ]; then - lib_extension="dylib" - elif [ "$platform" == "linux" ]; then - case "${arch}" in - x86_64 | amd64) lib_extension="x86_64.so" ;; - aarch64 | arm64) lib_extension="aarch64.so" ;; - *) echo "Unsupported arch $arch" && exit 1 ;; - esac else - echo "Unsupported platform $platform" - exit 1 + 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.2 "$plugin" + done fi - echo "$shared_lib_dir/${lib_name}.$lib_extension" -} -# global goreleaser before hook -# moves native libraries to temp directories used by docker images / archives -before_hook() { - local -r lib_path=tmp - # MOVE NATIVE LIBRARIES HERE - local -r wasmvm_lib_path_linux_amd64=$(_get_wasmvm_lib_path "linux" "amd64") - local -r wasmvm_lib_path_linux_arm64=$(_get_wasmvm_lib_path "linux" "arm64") - local -r wasmvm_lib_path_darwin_amd64=$(_get_wasmvm_lib_path "darwin" "amd64") - local -r wasmvm_lib_path_darwin_arm64=$(_get_wasmvm_lib_path "darwin" "arm64") - mkdir -p "$lib_path/linux_amd64/libs" - cp -f "$wasmvm_lib_path_linux_amd64" "$lib_path/linux_amd64/libs" - mkdir -p "$lib_path/linux_arm64/libs" - cp -f "$wasmvm_lib_path_linux_arm64" "$lib_path/linux_arm64/libs" - mkdir -p "$lib_path/darwin_amd64/libs" - cp -f "$wasmvm_lib_path_darwin_amd64" "$lib_path/darwin_amd64/libs" - mkdir -p "$lib_path/darwin_arm64/libs" - cp -f "$wasmvm_lib_path_darwin_arm64" "$lib_path/darwin_arm64/libs" - - # MOVE PLUGINS HERE - gobin=$(go env GOPATH)/bin - - install_local_plugins "linux" "amd64" "$gobin"/linux_amd64/ - install_remote_plugins "linux" "amd64" "$gobin"/linux_amd64/ - mkdir -p "$lib_path/linux_amd64/plugins" - cp "$gobin"/linux_amd64/chainlink* "$lib_path/linux_amd64/plugins" - cp "$gobin"/chainlink* "$lib_path/linux_amd64/plugins" - - install_local_plugins "linux" "arm64" "$gobin"/linux_arm64/ - install_remote_plugins "linux" "arm64" "$gobin"/linux_arm64/ - mkdir -p "$lib_path/linux_arm64/plugins" - cp "$gobin"/linux_arm64/chainlink* "$lib_path/linux_arm64/plugins" - cp "$gobin"/chainlink* "$lib_path/linux_arm64/plugins" } install_local_plugins() { - local -r goos=$1 - local -r goarch=$2 - local -r gobin=$3 - ldf="$(./tools/bin/ldflags)" - ldflags=(-ldflags "$ldf") - GOARCH=$goarch GOOS=$goos go build -o $gobin "${ldflags[@]}" ./plugins/cmd/chainlink-medianpoc - GOARCH=$goarch GOOS=$goos go build -o $gobin "${ldflags[@]}" ./plugins/cmd/chainlink-ocr3-capability + make install-medianpoc + make install-ocr3-capability } get_remote_plugin_paths() { @@ -105,13 +70,10 @@ get_remote_plugin_paths() { } install_remote_plugins() { - local -r goos=$1 - local -r goarch=$2 - local -r gobin=$(go env GOPATH)/bin ldflags=(-ldflags "$(./tools/bin/ldflags)") for plugin in $(get_remote_plugin_paths); do - GOARCH=$goarch GOOS=$goos go build -o $gobin "${ldflags[@]}" "$plugin" + go install "${ldflags[@]}" "$plugin" done } @@ -120,16 +82,14 @@ install_remote_plugins() { # moves native libraries to binary libs directory build_post_hook() { local -r dist_path=$1 + local -r plugin_src_path=./tmp/plugins + local -r wasmvm_lib_path=./tmp/libs local -r lib_dest_path=$dist_path/libs - local -r platform=$2 - local -r arch=$3 - local -r plugin_src_path=./tmp/${platform}_${arch}/plugins local -r plugin_dest_path=$dist_path/plugins # COPY NATIVE LIBRARIES HERE - local -r wasmvm_lib_path=$(_get_wasmvm_lib_path "$platform" "$arch") mkdir -p "$lib_dest_path" - cp "$wasmvm_lib_path" "$lib_dest_path" + cp -r "$wasmvm_lib_path/." "$lib_dest_path" # COPY PLUGINS HERE mkdir -p "$plugin_dest_path" diff --git a/tools/bin/goreleaser_wrapper b/tools/bin/goreleaser_wrapper deleted file mode 100755 index d4b16d1c54..0000000000 --- a/tools/bin/goreleaser_wrapper +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -set -euo pipefail -set -x -# get machine / kernel name -_get_platform() { - uname | tr '[:upper:]' '[:lower:]' -} - -# get macos sdk directory -_get_macos_sdk_dir() { - if [[ -z "${MACOS_SDK_DIR-}" ]]; then - platform=$(_get_platform) - if [[ "$platform" = 'darwin' ]]; then - if [[ "$(command -v xcrun)" ]]; then - echo "$(xcrun --sdk macosx --show-sdk-path)" - else - echo "You need to have MacOS Command Line Tools installed, you can install it via '$ xcode-select --install'" - exit 1 - fi - else - echo "You must set the MACOS_SDK_DIR env var to where you have the MacOS SDK installed" - echo "If you do not have a MacOS SDK installed, see https://github.com/joseluisq/macosx-sdks/tree/12.3 to obtain one" - exit 1 - fi - else - echo "$MACOS_SDK_DIR" - fi -} - -macos_sdk_dir=$(_get_macos_sdk_dir) -framework_search_path="/System/Library/Frameworks" -include_search_path='/usr/include' - -ZIG_FLAGS_DARWIN="-isysroot$macos_sdk_dir \ - -F$macos_sdk_dir$framework_search_path \ - -iframeworkwithsysroot$framework_search_path \ - -iwithsysroot$include_search_path \ - -mmacosx-version-min=11.7.1" \ -ZIG_EXEC=$(which zig) \ -CHAINLINK_VERSION=$(jq -r '.version' package.json) \ -goreleaser "$@" diff --git a/tools/bin/ldd_fix b/tools/bin/ldd_fix deleted file mode 100755 index dd48e9c3b3..0000000000 --- a/tools/bin/ldd_fix +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# This script is used as a temp fix the ldd linking of cosm lib for binary -# Currently there is an issue with the go linker not working with zig -# https://github.com/ziglang/zig/issues/18922 - -chainlink_path="/usr/local/bin/chainlink" -libs_path="/usr/local/bin/libs" - -line=$(ldd ${chainlink_path} | grep "github.com/!cosm!wasm/wasmvm") - -if [ -z "$line" ]; then - echo "Error: Path containing 'github.com/!cosm!wasm/wasmvm' not found in the ldd output." - exit 1 -fi - -path=$(echo "$line" | awk '{print $1}') - -if [ -z "$path" ]; then - echo "Error: Failed to extract the path from the line." - exit 1 -fi - -trimmed_path=${path%.so*}.so -cosm_file=$(ls ${libs_path} | grep "\.so$" | head -n 1) - -patchelf --remove-needed "${trimmed_path}" "$chainlink_path" -patchelf --add-needed "$cosm_file" "$chainlink_path" diff --git a/tools/goreleaser-config/gen_config.go b/tools/goreleaser-config/gen_config.go new file mode 100644 index 0000000000..f234920c10 --- /dev/null +++ b/tools/goreleaser-config/gen_config.go @@ -0,0 +1,391 @@ +package main + +import ( + "fmt" + "strings" + + "github.com/goreleaser/goreleaser-pro/v2/pkg/config" +) + +// Generate creates the goreleaser configuration based on the environment. +var validEnvironments = []string{"devspace", "develop"} + +func Generate(environment string) config.Project { + checkEnvironments(environment) + architectures := []string{"amd64", "arm64"} + + project := config.Project{ + ProjectName: "ccip", + Version: 2, + Env: commonEnv(environment), + Before: config.Before{ + Hooks: []config.Hook{ + { + Cmd: "go mod tidy", + }, + { + Cmd: "./tools/bin/goreleaser_utils before_hook", + }, + }, + }, + Builds: builds(environment), + Dockers: dockers(environment, architectures), + DockerManifests: dockerManifests(environment), + Checksum: config.Checksum{ + NameTemplate: "checksums.txt", + }, + Snapshot: config.Snapshot{ + VersionTemplate: "{{ .Env.VERSION }}-{{ .ShortCommit }}", + }, + Nightly: config.Nightly{ + VersionTemplate: "{{ .Env.VERSION }}-{{ .Env.IMG_TAG }}", + }, + Partial: config.Partial{ + By: "target", + }, + Release: config.Release{ + Disable: "true", + }, + Archives: []config.Archive{ + { + Format: "binary", + }, + }, + Changelog: config.Changelog{ + Disable: "true", + }, + Git: config.Git{ + IgnoreTags: []string{"contracts-ccip/v1.5.0-beta.0"}, + }, + } + + 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" { + project.Changelog = config.Changelog{ + Sort: "asc", + Filters: config.Filters{ + Exclude: []string{ + "^docs:", + "^test:", + }, + }, + } + project.Archives = []config.Archive{ + { + Format: "tar.gz", + }, + } + project.SBOMs = []config.SBOM{ + { + Artifacts: "archive", + }, + } + } + + return project +} + +func checkEnvironments(environment string) { + valid := false + for _, env := range validEnvironments { + if environment == env { + valid = true + break + } + } + if !valid { + panic(fmt.Sprintf("invalid environment: %s, valid environments are %v", environment, validEnvironments)) + } +} + +// commonEnv returns the common environment variables used across environments. +func commonEnv(environment string) []string { + envs := []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 }}`) + } + return envs +} + +// builds returns the build configurations based on the environment. +func builds(environment string) []config.Build { + switch environment { + case "devspace": + return []config.Build{ + build(true), + } + case "develop", "production": + return []config.Build{ + build(false), + } + + default: + return nil + } +} + +// build creates a build configuration. +func build(isDevspace bool) config.Build { + dynamicLinker := `{{ if contains .Runtime.Goarch "amd64" -}} +/lib64/ld-linux-x86-64.so.2 +{{- else if contains .Runtime.Goarch "arm64" -}} +/lib/ld-linux-aarch64.so.1 +{{- end }}` + + ldflags := []string{ + "-s -w -r=$ORIGIN/libs", + "-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 }}") + } + + return config.Build{ + Binary: "chainlink", + NoUniqueDistDir: "true", + Targets: []string{"go_first_class"}, + Hooks: config.BuildHookConfig{ + Post: []config.Hook{ + {Cmd: "./tools/bin/goreleaser_utils build_post_hook {{ dir .Path }}"}, + }, + }, + BuildDetails: config.BuildDetails{ + Flags: []string{"-trimpath", "-buildmode=pie"}, + Ldflags: ldflags, + }, + } +} + +// dockers returns the docker configurations based on the environment. +func dockers(environment string, architectures []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": + imageNames := []string{"ccip"} + + for _, imageName := range imageNames { + for _, arch := range architectures { + id := fmt.Sprintf("linux-%s-%s", arch, imageName) + pluginId := fmt.Sprintf("%s-plugins", id) + + dockers = append(dockers, docker(id, "linux", arch, environment, false)) + dockers = append(dockers, docker(pluginId, "linux", arch, environment, false)) + } + } + } + return dockers +} + +// docker creates a docker configuration. +func docker(id, goos, goarch, environment string, isDevspace bool) config.Docker { + isCCIP := strings.Contains(id, "ccip") + isPlugins := strings.Contains(id, "plugins") + extraFiles := []string{"tmp/libs"} + if isPlugins || isDevspace { + extraFiles = append(extraFiles, "tmp/plugins") + } + if isCCIP { + extraFiles = append(extraFiles, "ccip/config") + } + + buildFlagTemplates := []string{ + fmt.Sprintf("--platform=%s/%s", goos, goarch), + "--pull", + "--build-arg=CHAINLINK_USER=chainlink", + "--build-arg=COMMIT_SHA={{ .FullCommit }}", + } + + if strings.Contains(id, "ccip") { + buildFlagTemplates = append(buildFlagTemplates, + "--build-arg=CL_CHAIN_DEFAULTS=/chainlink/ccip-config") + } + + if strings.Contains(id, "plugins") || isDevspace { + buildFlagTemplates = append(buildFlagTemplates, + "--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", + ) + } + + buildFlagTemplates = append(buildFlagTemplates, + `--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`, + ) + if !isDevspace { + buildFlagTemplates = append(buildFlagTemplates, + `--label=org.opencontainers.image.version={{ .Env.VERSION }}`, + ) + } + + dockerConfig := config.Docker{ + ID: id, + Dockerfile: "core/chainlink.goreleaser.Dockerfile", + Use: "buildx", + Goos: goos, + Goarch: goarch, + Files: extraFiles, + BuildFlagTemplates: buildFlagTemplates, + } + + // We always want to build both versions as a test, but + // only push the relevant version based on the tag name + // + // We also expect the production config file to only be run during a tag push, + // enforced inside our github actions workflow, "build-publish" + if environment == "production" { + if isCCIP { + dockerConfig.SkipPush = "{{ not (contains .Tag \"-ccip\") }}" + } else { + dockerConfig.SkipPush = "{{ contains .Tag \"-ccip\" }}" + } + } + + // This section handles the image templates for the docker configuration + if environment == "devspace" { + dockerConfig.ImageTemplates = []string{"{{ .Env.IMAGE }}"} + } else { + base := "{{ .Env.IMG_PRE }}" + // On production envs, we have the ECR prefix for the image + if environment == "production" { + if isCCIP { + base = base + "/chainlink/chainlink-ccip-experimental-goreleaser" + } else { + base = base + "/chainlink/chainlink-experimental-goreleaser" + } + } else { + if isCCIP { + base = base + "/ccip" + } else { + base = base + "/chainlink" + } + } + + imageTemplates := []string{} + if strings.Contains(id, "plugins") { + taggedBase := fmt.Sprintf("%s:{{ .Env.IMG_TAG }}-plugins", base) + // We have a default, non-arch specific image for plugins that defaults to amd64 + if goarch == "amd64" { + imageTemplates = append(imageTemplates, taggedBase) + } + imageTemplates = append(imageTemplates, + fmt.Sprintf("%s-%s", taggedBase, archSuffix(id)), + fmt.Sprintf("%s:sha-{{ .ShortCommit }}-plugins-%s", base, archSuffix(id))) + } else { + taggedBase := fmt.Sprintf("%s:{{ .Env.IMG_TAG }}", base) + // We have a default, non-arch specific image for plugins that defaults to amd64 + if goarch == "amd64" { + imageTemplates = append(imageTemplates, taggedBase) + } + imageTemplates = append(imageTemplates, + fmt.Sprintf("%s-%s", taggedBase, archSuffix(id)), + fmt.Sprintf("%s:sha-{{ .ShortCommit }}-%s", base, archSuffix(id))) + } + + dockerConfig.ImageTemplates = imageTemplates + } + + return dockerConfig +} + +// archSuffix returns the architecture suffix for image tags. +func archSuffix(id string) string { + if strings.Contains(id, "arm64") { + return "arm64" + } + return "amd64" +} + +// dockerManifests returns the docker manifest configurations based on the environment. +func dockerManifests(environment string) []config.DockerManifest { + if environment == "devspace" { + return []config.DockerManifest{ + { + NameTemplate: "{{ .Env.IMAGE }}", + ImageTemplates: []string{"{{ .Env.IMAGE }}"}, + }, + } + } + + // Define the image names based on the environment + imageNames := []string{"chainlink", "ccip"} + + // FIXME: This is duplicated + if environment == "production" { + imageNames = []string{"chainlink/chainlink-experimental-goreleaser", "chainlink/chainlink-ccip-experimental-goreleaser"} + } + var manifests []config.DockerManifest + + for _, imageName := range imageNames { + fullImageName := fmt.Sprintf("{{ .Env.IMAGE_PREFIX }}/%s", imageName) + + manifestConfigs := []struct { + ID string + Suffix string + }{ + {ID: "tagged", Suffix: ":{{ .Env.IMG_TAG }}"}, + {ID: "sha", Suffix: ":sha-{{ .ShortCommit }}"}, + {ID: "tagged-plugins", Suffix: ":{{ .Env.IMG_TAG }}-plugins"}, + {ID: "sha-plugins", Suffix: ":sha-{{ .ShortCommit }}-plugins"}, + } + for _, cfg := range manifestConfigs { + nameTemplate := fmt.Sprintf("%s%s", fullImageName, cfg.Suffix) + manifest := config.DockerManifest{ + ID: strings.ReplaceAll(fmt.Sprintf("%s-%s", cfg.ID, imageName), "/", "-"), + NameTemplate: nameTemplate, + ImageTemplates: manifestImages(nameTemplate), + } + if environment == "production" { + if strings.Contains(nameTemplate, "ccip") { + manifest.SkipPush = "{{ not (contains .Tag \"-ccip\") }}" + } else { + manifest.SkipPush = "{{ contains .Tag \"-ccip\" }}" + } + } + manifests = append(manifests, manifest) + } + } + + return manifests +} + +// manifestImages generates image templates for docker manifests. +func manifestImages(imageName string) []string { + architectures := []string{"amd64", "arm64"} + var images []string + // Add the default image for tagged images + if !strings.Contains(imageName, "sha") { + images = append(images, imageName) + } + for _, arch := range architectures { + images = append(images, fmt.Sprintf("%s-%s", imageName, arch)) + } + return images +} diff --git a/tools/goreleaser-config/go.mod b/tools/goreleaser-config/go.mod new file mode 100644 index 0000000000..f46423b660 --- /dev/null +++ b/tools/goreleaser-config/go.mod @@ -0,0 +1,14 @@ +module github.com/smartcontractkit/chainlink/tools/goreleaser-config + +go 1.23.0 + +require ( + github.com/goreleaser/goreleaser-pro/v2 v2.3.2-pro + gopkg.in/yaml.v3 v3.0.1 +) + +require ( + github.com/kr/pretty v0.3.1 // indirect + github.com/rogpeppe/go-internal v1.12.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect +) diff --git a/tools/goreleaser-config/go.sum b/tools/goreleaser-config/go.sum new file mode 100644 index 0000000000..e823cbd7de --- /dev/null +++ b/tools/goreleaser-config/go.sum @@ -0,0 +1,19 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/goreleaser/goreleaser-pro/v2 v2.3.2-pro h1:9zJQ9cxvLn0JJZsjomtjOnSB9W4nrpFazZ7KxDZmuoU= +github.com/goreleaser/goreleaser-pro/v2 v2.3.2-pro/go.mod h1:GA7Uzk7qKA3efeDmgfWwcMTrDJe+V7D6H5RMqXlFvuc= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tools/goreleaser-config/main.go b/tools/goreleaser-config/main.go new file mode 100644 index 0000000000..e7376dfb89 --- /dev/null +++ b/tools/goreleaser-config/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "gopkg.in/yaml.v3" + "os" +) + +func main() { + environments := []string{"develop", "devspace"} + for _, e := range environments { + cfg := Generate(e) + data, err := yaml.Marshal(&cfg) + if err != nil { + panic(err) + } + filename := fmt.Sprintf("../../.goreleaser.%s.yaml", e) + err = os.WriteFile(filename, data, 0644) + if err != nil { + panic(err) + } + fmt.Printf("Generated %s\n", filename) + } +}