From be5b4b23a8464b89b9fa41824b9d675afbbb60b4 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 17:47:45 +0530 Subject: [PATCH 01/55] add a test github workflow --- .../workflows/test-cli-plugin-manifest.yaml | 93 +++++++++++++++++ crates/cli/src/lib.rs | 36 +++++-- crates/cli/src/metadata.rs | 99 +++++++++++++++++-- 3 files changed, 210 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/test-cli-plugin-manifest.yaml diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml new file mode 100644 index 00000000..0d92004c --- /dev/null +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -0,0 +1,93 @@ +name: Test CLI Plugin Manifest + +on: + pull_request: + branches: + - main + +env: + CARGO_TERM_COLOR: always + BINARY_NAME: your_cli_name + +jobs: + build: + name: Build Binary - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + binary_suffix: '' + - os: ubuntu-latest + target: aarch64-unknown-linux-gnu + binary_suffix: '' + - os: windows-latest + target: x86_64-pc-windows-msvc + binary_suffix: '.exe' + - os: macos-latest + target: x86_64-apple-darwin + binary_suffix: '' + - os: macos-latest + target: aarch64-apple-darwin + binary_suffix: '' + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Install cross-compilation tools + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get update + sudo apt-get install -y gcc-aarch64-linux-gnu + + - name: Build binary + run: cargo build --release --target ${{ matrix.target }} + + - name: Generate manifest entry + shell: bash + run: | + # Calculate SHA256 of the binary + if [ "${{ runner.os }}" = "Windows" ]; then + SHA256=$(certutil -hashfile target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.binary_suffix }} SHA256 | grep -v "hash" | awk '{print $1}') + else + SHA256=$(sha256sum target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.binary_suffix }} | cut -d' ' -f1) + fi + + # Create manifest entry + echo "{ + \"name\": \"${{ env.BINARY_NAME }}\", + \"target\": \"${{ matrix.target }}\", + \"sha256\": \"${SHA256}\", + \"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.event.pull_request.head.sha }}/${{ env.BINARY_NAME }}-${{ matrix.target }}${{ matrix.binary_suffix }}\" + }" > manifest-entry.json + + - name: Upload manifest entry + uses: actions/upload-artifact@v4 + with: + name: manifest-${{ matrix.target }} + path: manifest-entry.json + retention-days: 1 + + create-manifest: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download all manifest entries + uses: actions/download-artifact@v4 + with: + path: entries + + - name: Combine manifest entries + run: | + echo '{"binaries": [' > cli-manifest.json + find entries -name "manifest-entry.json" -exec cat {} \; | sed '$!s/$/,/' >> cli-manifest.json + echo ']}' >> cli-manifest.json + + echo "Generated CLI Plugin Manifest:" + cat cli-manifest.json diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 28fb91c5..3c6fcb5e 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -36,6 +36,9 @@ pub enum Command { #[arg(long)] /// Whether to create the hasura connector metadata. with_metadata: bool, + #[arg(long)] + /// The path to the binary CLI manifest. + binary_cli_manifest: PathBuf, }, /// Update the configuration by introspecting the database, using the configuration options. Update { @@ -54,7 +57,10 @@ pub enum Error { /// Run a command in a given directory. pub async fn run(command: Command, context: Context) -> anyhow::Result<()> { match command { - Command::Initialize { with_metadata } => initialize(with_metadata, context).await?, + Command::Initialize { + with_metadata, + binary_cli_manifest, + } => initialize(with_metadata, context, binary_cli_manifest).await?, Command::Update { subcommand } => update(context, subcommand).await?, }; Ok(()) @@ -68,11 +74,15 @@ pub async fn run(command: Command, context: Context) -> anyhow /// /// Optionally, this can also create the connector metadata, which is used by the Hasura CLI to /// automatically work with this CLI as a plugin. -async fn initialize(with_metadata: bool, context: Context) -> anyhow::Result<()> { +async fn initialize( + with_metadata: bool, + context: Context, + binary_cli_manifest: PathBuf, +) -> anyhow::Result<()> { let configuration_file = context .context_path .join(configuration::CONFIGURATION_FILENAME); - fs::create_dir_all(&context.context_path)?; // TODO(PY): .await + fs::create_dir_all(&context.context_path)?; // refuse to initialize the directory unless it is empty let mut items_in_dir = fs::read_dir(&context.context_path)?; @@ -97,12 +107,18 @@ async fn initialize(with_metadata: bool, context: Context) -> serde_json::to_string_pretty(&output)? + "\n", )?; + // Read and parse the binary CLI manifest directly into BinaryCliPluginPlatform + let manifest_contents = fs::read_to_string(&binary_cli_manifest)?; + let platforms: Vec = + serde_yaml::from_str(&manifest_contents)?; + // if requested, create the metadata if with_metadata { let metadata_dir = context.context_path.join(".hasura-connector"); let _ = fs::create_dir(&metadata_dir); let metadata_file = metadata_dir.join("connector-metadata.yaml"); let metadata = metadata::ConnectorMetadataDefinition { + version: Some("v1".to_string()), packaging_definition: metadata::PackagingDefinition::PrebuiltDockerImage( metadata::PrebuiltDockerImagePackaging { docker_image: format!( @@ -115,21 +131,25 @@ async fn initialize(with_metadata: bool, context: Context) -> name: "CONNECTION_URI".to_string(), description: "The SQL server connection URI".to_string(), default_value: None, + required: true, }], commands: metadata::Commands { - update: Some("hasura-ndc-sqlserver update".to_string()), + update: Some(metadata::Command::String( + "hasura-ndc-sqlserver update".to_string(), + )), watch: None, + print_schema_and_capabilities: None, + upgrade_configuration: None, }, - cli_plugin: Some(metadata::CliPluginDefinition { - name: "ndc-sqlserver".to_string(), - version: context.release_version.unwrap_or("latest").to_string(), - }), + cli_plugin: Some(metadata::CliPluginDefinition::BinaryInline { platforms }), docker_compose_watch: vec![metadata::DockerComposeWatchItem { path: "./".to_string(), target: Some("/etc/connector".to_string()), action: metadata::DockerComposeWatchAction::SyncAndRestart, ignore: vec![], }], + native_toolchain_definition: None, + documentation_page: None, }; fs::write(metadata_file, serde_yaml::to_string(&metadata)?)?; diff --git a/crates/cli/src/metadata.rs b/crates/cli/src/metadata.rs index 74d2c8d1..ed42af87 100644 --- a/crates/cli/src/metadata.rs +++ b/crates/cli/src/metadata.rs @@ -1,19 +1,25 @@ //! Structures that represent the connector metadata definition. //! -//! See https://github.com/hasura/ndc-hub/blob/main/rfcs/0001-packaging.md#connector-definition. +//! See https://github.com/hasura/ndc-hub/blob/main/rfcs/0011-cli-and-connector-packaging.md use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ConnectorMetadataDefinition { + #[serde(skip_serializing_if = "Option::is_none")] + pub version: Option, // "v1" pub packaging_definition: PackagingDefinition, + #[serde(skip_serializing_if = "Option::is_none")] + pub native_toolchain_definition: Option, pub supported_environment_variables: Vec, pub commands: Commands, #[serde(skip_serializing_if = "Option::is_none")] pub cli_plugin: Option, #[serde(skip_serializing_if = "Vec::is_empty")] pub docker_compose_watch: DockerComposeWatch, + #[serde(skip_serializing_if = "Option::is_none")] + pub documentation_page: Option, } #[derive(Debug, Serialize, Deserialize)] @@ -31,27 +37,100 @@ pub struct PrebuiltDockerImagePackaging { #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct EnvironmentVariableDefinition { - pub name: String, - pub description: String, +pub struct NativeToolchainDefinition { + pub commands: NativeToolchainCommands, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct NativeToolchainCommands { + pub start: Command, #[serde(skip_serializing_if = "Option::is_none")] - pub default_value: Option, + pub update: Option, + pub watch: Command, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(untagged)] +pub enum Command { + String(String), + Dockerized(DockerizedCommand), + ShellScript(ShellScriptCommand), } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct Commands { #[serde(skip_serializing_if = "Option::is_none")] - pub update: Option, + pub update: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub watch: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub print_schema_and_capabilities: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub watch: Option, + pub upgrade_configuration: Option, } #[derive(Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct CliPluginDefinition { +pub struct EnvironmentVariableDefinition { pub name: String, - pub version: String, + pub description: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub default_value: Option, + pub required: bool, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct DockerizedCommand { + #[serde(rename = "type")] + pub command_type: String, // "Dockerized" + pub docker_image: String, + pub command_args: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct ShellScriptCommand { + #[serde(rename = "type")] + pub command_type: String, // "ShellScript" + pub bash: String, + pub powershell: String, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(tag = "type", rename_all = "PascalCase")] +pub enum CliPluginDefinition { + Binary { + name: String, + version: String, + }, + BinaryInline { + platforms: Vec, + }, + Docker { + docker_image: String, + }, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct BinaryCliPluginPlatform { + pub selector: PlatformSelector, + pub uri: String, + pub sha256: String, + pub bin: String, +} + +#[derive(Debug, Serialize, Deserialize)] +#[serde(rename_all = "kebab-case")] +pub enum PlatformSelector { + DarwinArm64, + LinuxArm64, + DarwinAmd64, + WindowsAmd64, + LinuxAmd64, } pub type DockerComposeWatch = Vec; @@ -60,9 +139,9 @@ pub type DockerComposeWatch = Vec; #[serde(rename_all = "camelCase")] pub struct DockerComposeWatchItem { pub path: String, + pub action: DockerComposeWatchAction, #[serde(skip_serializing_if = "Option::is_none")] pub target: Option, - pub action: DockerComposeWatchAction, #[serde(skip_serializing_if = "Vec::is_empty")] pub ignore: Vec, } From 289a53c5f4ef64bc9b32080c1fc98bb79a748ab7 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 17:53:13 +0530 Subject: [PATCH 02/55] don't change anything --- .../workflows/test-cli-plugin-manifest.yaml | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 0d92004c..1e046e42 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -10,29 +10,33 @@ env: BINARY_NAME: your_cli_name jobs: - build: - name: Build Binary - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - binary_suffix: '' - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - binary_suffix: '' - - os: windows-latest - target: x86_64-pc-windows-msvc - binary_suffix: '.exe' - - os: macos-latest - target: x86_64-apple-darwin - binary_suffix: '' - - os: macos-latest - target: aarch64-apple-darwin - binary_suffix: '' - - steps: + name: build the CLI binaries + strategy: + matrix: + include: + - runner: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + - runner: ubuntu-20.04 + target: aarch64-unknown-linux-gnu + linux-packages: gcc-aarch64-linux-gnu + linker: /usr/bin/aarch64-linux-gnu-gcc + - runner: macos-latest + target: x86_64-apple-darwin + - runner: macos-latest + target: aarch64-apple-darwin + - runner: windows-latest + target: x86_64-pc-windows-msvc + extension: .exe + extra-rust-flags: "-C target-feature=+crt-static" + runs-on: ${{ matrix.runner }} + env: + CARGO_BUILD_TARGET: ${{ matrix.target }} + CARGO_NET_GIT_FETCH_WITH_CLI: "true" + RUSTFLAGS: "-D warnings" # fail on warnings + defaults: + run: + shell: bash + steps: - uses: actions/checkout@v4 - name: Install Rust From abe163327b0b2f58e5eac7f25cafca8a5ca03d2d Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 17:58:05 +0530 Subject: [PATCH 03/55] add workflow_dispatch --- .github/workflows/test-cli-plugin-manifest.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 1e046e42..d244c19f 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -1,6 +1,7 @@ name: Test CLI Plugin Manifest on: + workflow_dispatch: pull_request: branches: - main From 196330a2f20e9b38afc9b7b6bdc7496b3e0de7f0 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 18:02:40 +0530 Subject: [PATCH 04/55] fix indentation --- .../workflows/test-cli-plugin-manifest.yaml | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index d244c19f..b42e8a1d 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -11,33 +11,34 @@ env: BINARY_NAME: your_cli_name jobs: - name: build the CLI binaries - strategy: - matrix: - include: - - runner: ubuntu-20.04 - target: x86_64-unknown-linux-gnu - - runner: ubuntu-20.04 - target: aarch64-unknown-linux-gnu - linux-packages: gcc-aarch64-linux-gnu - linker: /usr/bin/aarch64-linux-gnu-gcc - - runner: macos-latest - target: x86_64-apple-darwin - - runner: macos-latest - target: aarch64-apple-darwin - - runner: windows-latest - target: x86_64-pc-windows-msvc - extension: .exe - extra-rust-flags: "-C target-feature=+crt-static" - runs-on: ${{ matrix.runner }} - env: - CARGO_BUILD_TARGET: ${{ matrix.target }} - CARGO_NET_GIT_FETCH_WITH_CLI: "true" + build: + name: Build the CLI binaries + strategy: + matrix: + include: + - runner: ubuntu-20.04 + target: x86_64-unknown-linux-gnu + - runner: ubuntu-20.04 + target: aarch64-unknown-linux-gnu + linux-packages: gcc-aarch64-linux-gnu + linker: /usr/bin/aarch64-linux-gnu-gcc + - runner: macos-latest + target: x86_64-apple-darwin + - runner: macos-latest + target: aarch64-apple-darwin + - runner: windows-latest + target: x86_64-pc-windows-msvc + extension: .exe + extra-rust-flags: "-C target-feature=+crt-static" + runs-on: ${{ matrix.runner }} + env: + CARGO_BUILD_TARGET: ${{ matrix.target }} + CARGO_NET_GIT_FETCH_WITH_CLI: "true" RUSTFLAGS: "-D warnings" # fail on warnings - defaults: - run: - shell: bash - steps: + defaults: + run: + shell: bash + steps: - uses: actions/checkout@v4 - name: Install Rust From 49c74fb6e1bcd4b5018d48d6a43bfb702d7a158d Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 18:06:11 +0530 Subject: [PATCH 05/55] add nix-build step --- .../workflows/test-cli-plugin-manifest.yaml | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index b42e8a1d..cd31e252 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -11,6 +11,48 @@ env: BINARY_NAME: your_cli_name jobs: + nix-build: + name: nix build + runs-on: ubuntu-latest + strategy: + matrix: + target: + - x86_64-linux + - aarch64-linux + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4 + + - name: Install Nix ❄ + uses: cachix/install-nix-action@v30 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up the Nix Cache 🔌 + uses: cachix/cachix-action@v15 + with: + name: hasura-v3-dev + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + useDaemon: false # attempt to stop hanging on cleanup + + - name: Build a binary with Nix + run: nix build --print-build-logs '.#${{ matrix.target }}' + + - name: Build a Docker image with Nix + run: nix build --print-build-logs '.#docker-${{ matrix.target }}' + + # scream into Slack if something goes wrong + - name: Report Status + if: always() && github.ref == 'refs/heads/main' + uses: ravsamhq/notify-slack-action@v2 + with: + status: ${{ job.status }} + notify_when: failure + notification_title: "😧 Error on <{repo_url}|{repo}>" + message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>" + env: + SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }} + build: name: Build the CLI binaries strategy: From 00c4aa4e7d8a94587178696a854ec08821f2b697 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 18:12:27 +0530 Subject: [PATCH 06/55] First generate the binaries correctly --- .../workflows/test-cli-plugin-manifest.yaml | 181 +++++++++--------- 1 file changed, 90 insertions(+), 91 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index cd31e252..76984931 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -11,50 +11,8 @@ env: BINARY_NAME: your_cli_name jobs: - nix-build: - name: nix build - runs-on: ubuntu-latest - strategy: - matrix: - target: - - x86_64-linux - - aarch64-linux - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v4 - - - name: Install Nix ❄ - uses: cachix/install-nix-action@v30 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up the Nix Cache 🔌 - uses: cachix/cachix-action@v15 - with: - name: hasura-v3-dev - authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} - useDaemon: false # attempt to stop hanging on cleanup - - - name: Build a binary with Nix - run: nix build --print-build-logs '.#${{ matrix.target }}' - - - name: Build a Docker image with Nix - run: nix build --print-build-logs '.#docker-${{ matrix.target }}' - - # scream into Slack if something goes wrong - - name: Report Status - if: always() && github.ref == 'refs/heads/main' - uses: ravsamhq/notify-slack-action@v2 - with: - status: ${{ job.status }} - notify_when: failure - notification_title: "😧 Error on <{repo_url}|{repo}>" - message_format: "🐴 *{workflow}* {status_message} for <{repo_url}|{repo}>" - env: - SLACK_WEBHOOK_URL: ${{ secrets.BROKEN_BUILD_SLACK_WEBHOOK_URL }} - - build: - name: Build the CLI binaries + build-cli-binaries: + name: build the CLI binaries strategy: matrix: include: @@ -83,59 +41,100 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Install Rust - uses: dtolnay/rust-toolchain@stable + - name: install protoc + uses: arduino/setup-protoc@v3 with: - targets: ${{ matrix.target }} + version: "25.x" + repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install cross-compilation tools - if: matrix.target == 'aarch64-unknown-linux-gnu' + - name: install tools run: | - sudo apt-get update - sudo apt-get install -y gcc-aarch64-linux-gnu + rustup show + rustup target add ${{ matrix.target }} - - name: Build binary - run: cargo build --release --target ${{ matrix.target }} + - name: install other packages required + if: matrix.linux-packages + run: | + sudo apt-get update + sudo apt-get install -y ${{ matrix.linux-packages }} - - name: Generate manifest entry - shell: bash + - name: build the CLI run: | - # Calculate SHA256 of the binary - if [ "${{ runner.os }}" = "Windows" ]; then - SHA256=$(certutil -hashfile target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.binary_suffix }} SHA256 | grep -v "hash" | awk '{print $1}') - else - SHA256=$(sha256sum target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.binary_suffix }} | cut -d' ' -f1) + # If we're on a tag, use the tag name as the release version. + if [[ "$GITHUB_REF_TYPE" == 'tag' ]]; then + # Ensure that the version specified in Cargo.toml is the same as the tag (with a 'v' prefix). + CARGO_VERSION="$(cargo metadata --format-version=1 | jq -r '.packages | .[] | select(.name == "ndc-sqlserver") | .version')" + echo "Git tag: ${GIT_REF_NAME}" + echo "Cargo version: ${CARGO_VERSION}" + + if [[ "$GITHUB_REF_NAME" != "v${CARGO_VERSION}" ]]; then + echo >&2 "The Git tag is \"${GITHUB_REF_NAME}\", but the version in Cargo.toml is \"${CARGO_VERSION}\"." + echo >&2 'These must be the same, with a "v" prefix for the tag. Aborting.' + exit 1 + fi + export RELEASE_VERSION="$GITHUB_REF_NAME" + echo "RELEASE_VERSION = ${RELEASE_VERSION}" fi - # Create manifest entry - echo "{ - \"name\": \"${{ env.BINARY_NAME }}\", - \"target\": \"${{ matrix.target }}\", - \"sha256\": \"${SHA256}\", - \"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.event.pull_request.head.sha }}/${{ env.BINARY_NAME }}-${{ matrix.target }}${{ matrix.binary_suffix }}\" - }" > manifest-entry.json - - - name: Upload manifest entry - uses: actions/upload-artifact@v4 - with: - name: manifest-${{ matrix.target }} - path: manifest-entry.json - retention-days: 1 - - create-manifest: - needs: build - runs-on: ubuntu-latest - steps: - - name: Download all manifest entries - uses: actions/download-artifact@v4 - with: - path: entries - - - name: Combine manifest entries - run: | - echo '{"binaries": [' > cli-manifest.json - find entries -name "manifest-entry.json" -exec cat {} \; | sed '$!s/$/,/' >> cli-manifest.json - echo ']}' >> cli-manifest.json + if [[ -n '${{ matrix.linker }}' ]]; then + TARGET_SCREAMING="$(echo '${{ matrix.target }}' | tr '[:lower:]' '[:upper:]' | tr '-' '_')" + echo "CARGO_TARGET_${TARGET_SCREAMING}_LINKER"='${{ matrix.linker }}' + declare "CARGO_TARGET_${TARGET_SCREAMING}_LINKER"='${{ matrix.linker }}' + export "CARGO_TARGET_${TARGET_SCREAMING}_LINKER" + fi - echo "Generated CLI Plugin Manifest:" - cat cli-manifest.json + if [[ -n '${{ matrix.extra-rust-flags }}' ]]; then + RUSTFLAGS="${RUSTFLAGS} ${{ matrix.extra-rust-flags }}" + export RUSTFLAGS + fi + echo "RUSTFLAGS = ${RUSTFLAGS}" + + echo "Building for target: ${CARGO_BUILD_TARGET}" + cargo build --release --bin ndc-sqlserver-cli + + mkdir -p release + mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli release/ndc-sqlserver-cli-${{ matrix.target }}${{ matrix.extension }} + echo "Generated binary successfully" + + # - name: Generate manifest entry + # shell: bash + # run: | + # # Calculate SHA256 of the binary + # if [ "${{ runner.os }}" = "Windows" ]; then + # SHA256=$(certutil -hashfile target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.binary_suffix }} SHA256 | grep -v "hash" | awk '{print $1}') + # else + # SHA256=$(sha256sum target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.binary_suffix }} | cut -d' ' -f1) + # fi + + # # Create manifest entry + # echo "{ + # \"name\": \"${{ env.BINARY_NAME }}\", + # \"target\": \"${{ matrix.target }}\", + # \"sha256\": \"${SHA256}\", + # \"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.event.pull_request.head.sha }}/${{ env.BINARY_NAME }}-${{ matrix.target }}${{ matrix.binary_suffix }}\" + # }" > manifest-entry.json + + # - name: Upload manifest entry + # uses: actions/upload-artifact@v4 + # with: + # name: manifest-${{ matrix.target }} + # path: manifest-entry.json + # retention-days: 1 + + # create-manifest: + # needs: build + # runs-on: ubuntu-latest + # steps: + # - name: Download all manifest entries + # uses: actions/download-artifact@v4 + # with: + # path: entries + + # - name: Combine manifest entries + # run: | + # echo '{"binaries": [' > cli-manifest.json + # find entries -name "manifest-entry.json" -exec cat {} \; | sed '$!s/$/,/' >> cli-manifest.json + # echo ']}' >> cli-manifest.json + + # echo "Generated CLI Plugin Manifest:" + # cat cli-manifest.json From 780e40d25fb24139b23512dceba0d1d1942ada84 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 18:43:01 +0530 Subject: [PATCH 07/55] generate the CLI plugin manifest --- .../workflows/test-cli-plugin-manifest.yaml | 77 ++++++++++++++----- 1 file changed, 57 insertions(+), 20 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 76984931..59c30a8e 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -18,15 +18,20 @@ jobs: include: - runner: ubuntu-20.04 target: x86_64-unknown-linux-gnu + platform: linux-amd64 - runner: ubuntu-20.04 target: aarch64-unknown-linux-gnu linux-packages: gcc-aarch64-linux-gnu linker: /usr/bin/aarch64-linux-gnu-gcc + platform: linux-arm64 - runner: macos-latest target: x86_64-apple-darwin + platform: darwin-amd64 - runner: macos-latest target: aarch64-apple-darwin + platform: darwin-arm64 - runner: windows-latest + platform: windows-amd64 target: x86_64-pc-windows-msvc extension: .exe extra-rust-flags: "-C target-feature=+crt-static" @@ -92,9 +97,41 @@ jobs: echo "Building for target: ${CARGO_BUILD_TARGET}" cargo build --release --bin ndc-sqlserver-cli - mkdir -p release - mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli release/ndc-sqlserver-cli-${{ matrix.target }}${{ matrix.extension }} - echo "Generated binary successfully" + # Create platform-specific directory under cli/ + mkdir -p cli/${{ matrix.platform }} + + # Move the binary with the correct name + if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then + mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli${{ matrix.extension }} cli/${{ matrix.target }}/hasura-ndc-sqlserver.exe + else + mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli cli/${{ matrix.target }}/hasura-ndc-sqlserver + fi + + - name: Generate manifest entry + shell: bash + run: | + + # Calculate SHA256 of the binary + if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then + SHA256=$(certutil -hashfile cli/${{ matrix.target }}/hasura-ndc-sqlserver.exe SHA256 | grep -v "hash" | awk '{print $1}') + else + SHA256=$(sha256sum cli/${{ matrix.target }}/hasura-ndc-sqlserver | cut -d' ' -f1) + fi + + # Create manifest entry + echo "{ + \"name\": \"hasura-ndc-sqlserver\", + \"platform\": \"${{ matrix.platform }}\", + \"sha256\": \"${SHA256}\", + \"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.event.pull_request.head.sha }}/hasura-ndc-sqlserver-${{ matrix.platform }}${{ matrix.extension }}\" + }" > manifest-entry.json + + - name: Upload manifest entry + uses: actions/upload-artifact@v4 + with: + name: manifest-${{ matrix.platform }} + path: manifest-entry.json + retention-days: 1 # - name: Generate manifest entry # shell: bash @@ -121,20 +158,20 @@ jobs: # path: manifest-entry.json # retention-days: 1 - # create-manifest: - # needs: build - # runs-on: ubuntu-latest - # steps: - # - name: Download all manifest entries - # uses: actions/download-artifact@v4 - # with: - # path: entries - - # - name: Combine manifest entries - # run: | - # echo '{"binaries": [' > cli-manifest.json - # find entries -name "manifest-entry.json" -exec cat {} \; | sed '$!s/$/,/' >> cli-manifest.json - # echo ']}' >> cli-manifest.json - - # echo "Generated CLI Plugin Manifest:" - # cat cli-manifest.json + create-manifest: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download all manifest entries + uses: actions/download-artifact@v4 + with: + path: entries + + - name: Combine manifest entries + run: | + echo '{"binaries": [' > cli-manifest.json + find entries -name "manifest-entry.json" -exec cat {} \; | sed '$!s/$/,/' >> cli-manifest.json + echo ']}' >> cli-manifest.json + + echo "Generated CLI Plugin Manifest:" + cat cli-manifest.json From c2f6c41aa7c63772c5fb37339109043776dfd3ba Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 18:47:56 +0530 Subject: [PATCH 08/55] build-cli-binaries --- .github/workflows/test-cli-plugin-manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 59c30a8e..d1c5dacc 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -159,7 +159,7 @@ jobs: # retention-days: 1 create-manifest: - needs: build + needs: build-cli-binaries runs-on: ubuntu-latest steps: - name: Download all manifest entries From c074a818277ccb869005259250aca2cfdc044c25 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 18:53:40 +0530 Subject: [PATCH 09/55] use matrix.platform --- .github/workflows/test-cli-plugin-manifest.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index d1c5dacc..30f67e7b 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -102,9 +102,9 @@ jobs: # Move the binary with the correct name if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then - mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli${{ matrix.extension }} cli/${{ matrix.target }}/hasura-ndc-sqlserver.exe + mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli${{ matrix.extension }} cli/${{ matrix.platform }}/hasura-ndc-sqlserver.exe else - mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli cli/${{ matrix.target }}/hasura-ndc-sqlserver + mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli cli/${{ matrix.platform }}/hasura-ndc-sqlserver fi - name: Generate manifest entry From 4bbbb36d5b18a67b46c8af44c1176b6c06cd9cb4 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 18:56:50 +0530 Subject: [PATCH 10/55] same thing again --- .github/workflows/test-cli-plugin-manifest.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 30f67e7b..753a3c73 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -113,9 +113,9 @@ jobs: # Calculate SHA256 of the binary if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then - SHA256=$(certutil -hashfile cli/${{ matrix.target }}/hasura-ndc-sqlserver.exe SHA256 | grep -v "hash" | awk '{print $1}') + SHA256=$(certutil -hashfile cli/${{ matrix.platform }}/hasura-ndc-sqlserver.exe SHA256 | grep -v "hash" | awk '{print $1}') else - SHA256=$(sha256sum cli/${{ matrix.target }}/hasura-ndc-sqlserver | cut -d' ' -f1) + SHA256=$(sha256sum cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) fi # Create manifest entry From a8ae2e0ec5a56f51f972fadc76b7c93fb83106ba Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 19:02:15 +0530 Subject: [PATCH 11/55] handle macos separately --- .github/workflows/test-cli-plugin-manifest.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 753a3c73..d9cd25d0 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -27,9 +27,11 @@ jobs: - runner: macos-latest target: x86_64-apple-darwin platform: darwin-amd64 + os: macOS - runner: macos-latest target: aarch64-apple-darwin platform: darwin-arm64 + os: macOS - runner: windows-latest platform: windows-amd64 target: x86_64-pc-windows-msvc @@ -114,6 +116,8 @@ jobs: # Calculate SHA256 of the binary if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then SHA256=$(certutil -hashfile cli/${{ matrix.platform }}/hasura-ndc-sqlserver.exe SHA256 | grep -v "hash" | awk '{print $1}') + elif [[ "${{ matrix.os }}" == "macOS" ]]; then + SHA256=$(shasum -a 256 cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) else SHA256=$(sha256sum cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) fi From 3ddbe12eb8fcd2f6cc1de1da2e560522da2b9ff6 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 19:11:22 +0530 Subject: [PATCH 12/55] use yaml --- .../workflows/test-cli-plugin-manifest.yaml | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index d9cd25d0..96e4250c 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -122,19 +122,18 @@ jobs: SHA256=$(sha256sum cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) fi - # Create manifest entry - echo "{ - \"name\": \"hasura-ndc-sqlserver\", - \"platform\": \"${{ matrix.platform }}\", - \"sha256\": \"${SHA256}\", - \"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.event.pull_request.head.sha }}/hasura-ndc-sqlserver-${{ matrix.platform }}${{ matrix.extension }}\" - }" > manifest-entry.json + cat << EOF > manifest-entry.yaml +- selector: ${{ matrix.platform }} + uri: "https://github.com/${{ github.repository }}/releases/download/v2.0.0-test/cli.tar.gz" + sha256: "${SHA256}" + bin: "${BIN_PATH}" +EOF - name: Upload manifest entry uses: actions/upload-artifact@v4 with: name: manifest-${{ matrix.platform }} - path: manifest-entry.json + path: manifest-entry.yaml retention-days: 1 # - name: Generate manifest entry @@ -171,11 +170,11 @@ jobs: with: path: entries + - name: Combine manifest entries run: | - echo '{"binaries": [' > cli-manifest.json - find entries -name "manifest-entry.json" -exec cat {} \; | sed '$!s/$/,/' >> cli-manifest.json - echo ']}' >> cli-manifest.json + # Combine all yaml entries into a single file + find entries -name "manifest-entry.yaml" -exec cat {} \; > cli-manifest.yaml echo "Generated CLI Plugin Manifest:" - cat cli-manifest.json + cat cli-manifest.yaml From 35c961f2111b321f7339570864ee0e8ad6ad479f Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 19:13:15 +0530 Subject: [PATCH 13/55] fix indentation --- .github/workflows/test-cli-plugin-manifest.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 96e4250c..ccbb8f1f 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -123,11 +123,11 @@ jobs: fi cat << EOF > manifest-entry.yaml -- selector: ${{ matrix.platform }} - uri: "https://github.com/${{ github.repository }}/releases/download/v2.0.0-test/cli.tar.gz" - sha256: "${SHA256}" - bin: "${BIN_PATH}" -EOF + - selector: ${{ matrix.platform }} + uri: "https://github.com/${{ github.repository }}/releases/download/v2.0.0-test/cli.tar.gz" + sha256: "${SHA256}" + bin: "${BIN_PATH}" + EOF - name: Upload manifest entry uses: actions/upload-artifact@v4 From b08aaae7fc2c230bd2266db95792d7e9afb6503e Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Wed, 22 Jan 2025 19:22:02 +0530 Subject: [PATCH 14/55] include correct bin --- .github/workflows/test-cli-plugin-manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index ccbb8f1f..5cf28ede 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -126,7 +126,7 @@ jobs: - selector: ${{ matrix.platform }} uri: "https://github.com/${{ github.repository }}/releases/download/v2.0.0-test/cli.tar.gz" sha256: "${SHA256}" - bin: "${BIN_PATH}" + bin: "${{matrix.platform}}/hasura-ndc-sqlserver${{ matrix.extension }}" EOF - name: Upload manifest entry From 9b14ebe25cf01437c1c8ae7a4e69ec9b64a67440 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 12:42:20 +0530 Subject: [PATCH 15/55] Generate connector package --- .github/workflows/test-cli-plugin-manifest.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 5cf28ede..c1ba0c8c 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -178,3 +178,9 @@ jobs: echo "Generated CLI Plugin Manifest:" cat cli-manifest.yaml + + - name: generate a connector package + run: | + chmod +x ./release/artifacts/ndc-sqlserver-cli-* + ./release/artifacts/ndc-sqlserver-cli-x86_64-unknown-linux-gnu --context=release/package initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + echo "$(tree release/package)" From cfa39f5e8a16b918a6be3e83d7bb59f4cf1be79c Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 12:51:43 +0530 Subject: [PATCH 16/55] trust AI --- .github/workflows/test-cli-plugin-manifest.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index c1ba0c8c..77540860 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -181,6 +181,6 @@ jobs: - name: generate a connector package run: | - chmod +x ./release/artifacts/ndc-sqlserver-cli-* - ./release/artifacts/ndc-sqlserver-cli-x86_64-unknown-linux-gnu --context=release/package initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml - echo "$(tree release/package)" + chmod +x cli/linux-amd64/hasura-ndc-sqlserver + ./cli/linux-amd64/hasura-ndc-sqlserver initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + echo "$(tree .)" From a5f6f37313626686434b28fe74f326b4827f3537 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 13:01:16 +0530 Subject: [PATCH 17/55] add debug statement --- .github/workflows/test-cli-plugin-manifest.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 77540860..31ecdc83 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -181,6 +181,7 @@ jobs: - name: generate a connector package run: | - chmod +x cli/linux-amd64/hasura-ndc-sqlserver - ./cli/linux-amd64/hasura-ndc-sqlserver initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml - echo "$(tree .)" + sudo apt-get update && sudo apt-get install -y tree + echo "${tree .}" + chmod +x cli/x86_64-unknown-linux-gnu/hasura-ndc-sqlserver + ./cli/x86_64-unknown-linux-gnu/hasura-ndc-sqlserver initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml From d0e80440e3e27fdda7c0aac5f0e20b2a1858901c Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 13:17:44 +0530 Subject: [PATCH 18/55] upload the binary --- .../workflows/test-cli-plugin-manifest.yaml | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 31ecdc83..675f4a77 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -136,7 +136,18 @@ jobs: path: manifest-entry.yaml retention-days: 1 - # - name: Generate manifest entry + - name: Upload linux-amd64 binary + uses: actions/upload-artifact@v4 + if: matrix.platform == 'linux-amd64' + with: + name: linux-binary + path: cli/${{ matrix.platform }}/hasura-ndc-sqlserver + retention-days: 1 + + + + + # name: Generate manifest entry # shell: bash # run: | # # Calculate SHA256 of the binary @@ -170,6 +181,11 @@ jobs: with: path: entries + - name: Download linux binary + uses: actions/download-artifact@v4 + with: + name: linux-binary + path: cli/linux-amd64 - name: Combine manifest entries run: | @@ -182,6 +198,6 @@ jobs: - name: generate a connector package run: | sudo apt-get update && sudo apt-get install -y tree - echo "${tree .}" - chmod +x cli/x86_64-unknown-linux-gnu/hasura-ndc-sqlserver - ./cli/x86_64-unknown-linux-gnu/hasura-ndc-sqlserver initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + tree . + chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver + ./cli/linux-amd64/hasura-ndc-sqlserver initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml From 1e52d257a11f8d96c622b0f46673a214ad95484e Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 13:24:13 +0530 Subject: [PATCH 19/55] fix spacing --- .github/workflows/test-cli-plugin-manifest.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 675f4a77..fe21730f 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -181,11 +181,11 @@ jobs: with: path: entries - - name: Download linux binary - uses: actions/download-artifact@v4 - with: - name: linux-binary - path: cli/linux-amd64 + - name: Download linux binary + uses: actions/download-artifact@v4 + with: + name: linux-binary + path: cli/linux-amd64 - name: Combine manifest entries run: | From 07bb204c1dfebeb86c8a22808ee4c089773bbeba Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 13:33:07 +0530 Subject: [PATCH 20/55] create configuration --- .github/workflows/test-cli-plugin-manifest.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index fe21730f..e3dbdee5 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -200,4 +200,6 @@ jobs: sudo apt-get update && sudo apt-get install -y tree tree . chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver - ./cli/linux-amd64/hasura-ndc-sqlserver initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + mkdir -p configuration + ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + cat configuration/.hasura-connector/connector-metadata.yaml From 1ed8198592dee00acb180b4ffd09f7ffb12f9f8f Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 13:33:33 +0530 Subject: [PATCH 21/55] create empty folder --- .github/workflows/test-cli-plugin-manifest.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index e3dbdee5..61768c22 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -197,8 +197,6 @@ jobs: - name: generate a connector package run: | - sudo apt-get update && sudo apt-get install -y tree - tree . chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver mkdir -p configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml From 53a56b759b3b72b4b99fa212867117ca4d20799e Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 13:59:31 +0530 Subject: [PATCH 22/55] upload the tarball as an artifact --- .../workflows/test-cli-plugin-manifest.yaml | 36 +++++-------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 61768c22..00f89fcf 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -144,34 +144,6 @@ jobs: path: cli/${{ matrix.platform }}/hasura-ndc-sqlserver retention-days: 1 - - - - # name: Generate manifest entry - # shell: bash - # run: | - # # Calculate SHA256 of the binary - # if [ "${{ runner.os }}" = "Windows" ]; then - # SHA256=$(certutil -hashfile target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.binary_suffix }} SHA256 | grep -v "hash" | awk '{print $1}') - # else - # SHA256=$(sha256sum target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}${{ matrix.binary_suffix }} | cut -d' ' -f1) - # fi - - # # Create manifest entry - # echo "{ - # \"name\": \"${{ env.BINARY_NAME }}\", - # \"target\": \"${{ matrix.target }}\", - # \"sha256\": \"${SHA256}\", - # \"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.event.pull_request.head.sha }}/${{ env.BINARY_NAME }}-${{ matrix.target }}${{ matrix.binary_suffix }}\" - # }" > manifest-entry.json - - # - name: Upload manifest entry - # uses: actions/upload-artifact@v4 - # with: - # name: manifest-${{ matrix.target }} - # path: manifest-entry.json - # retention-days: 1 - create-manifest: needs: build-cli-binaries runs-on: ubuntu-latest @@ -201,3 +173,11 @@ jobs: mkdir -p configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml cat configuration/.hasura-connector/connector-metadata.yaml + tar vczf release/artifacts/package.tar.gz -C configuration . + + - name: Upload connector package + uses: actions/upload-artifact@v4 + with: + name: package.tar.gz + path: release/artifacts/package.tar.gz + retention-days: 1 From 799ede35f1f1b8aed1b3e77f2f125d1d4fa49a85 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 14:48:01 +0530 Subject: [PATCH 23/55] fix indentation --- .github/workflows/test-cli-plugin-manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 00f89fcf..3d93e13e 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -173,7 +173,7 @@ jobs: mkdir -p configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml cat configuration/.hasura-connector/connector-metadata.yaml - tar vczf release/artifacts/package.tar.gz -C configuration . + tar vczf release/artifacts/package.tar.gz -C configuration configuration - name: Upload connector package uses: actions/upload-artifact@v4 From b1467c135f7bffaa64a2f4871b362d0566a32749 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 14:48:50 +0530 Subject: [PATCH 24/55] fix indentation --- .github/workflows/test-cli-plugin-manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 3d93e13e..1239fafd 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -173,7 +173,7 @@ jobs: mkdir -p configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml cat configuration/.hasura-connector/connector-metadata.yaml - tar vczf release/artifacts/package.tar.gz -C configuration configuration + tar vczf release/artifacts/package.tar.gz -C configuration . - name: Upload connector package uses: actions/upload-artifact@v4 From bc9bb573b3f256bc39f83064aadf16726e296b08 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 14:57:43 +0530 Subject: [PATCH 25/55] fix the path of the connector package --- .github/workflows/test-cli-plugin-manifest.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 1239fafd..a65eb391 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -32,11 +32,11 @@ jobs: target: aarch64-apple-darwin platform: darwin-arm64 os: macOS - - runner: windows-latest - platform: windows-amd64 - target: x86_64-pc-windows-msvc - extension: .exe - extra-rust-flags: "-C target-feature=+crt-static" + # - runner: windows-latest + # platform: windows-amd64 + # target: x86_64-pc-windows-msvc + # extension: .exe + # extra-rust-flags: "-C target-feature=+crt-static" runs-on: ${{ matrix.runner }} env: CARGO_BUILD_TARGET: ${{ matrix.target }} @@ -173,11 +173,10 @@ jobs: mkdir -p configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml cat configuration/.hasura-connector/connector-metadata.yaml - tar vczf release/artifacts/package.tar.gz -C configuration . + tar vczf package.tar.gz -C configuration . - name: Upload connector package uses: actions/upload-artifact@v4 with: name: package.tar.gz - path: release/artifacts/package.tar.gz retention-days: 1 From 86946ee38cc23cecf2026c2bd569015b5b5c8759 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 15:01:15 +0530 Subject: [PATCH 26/55] just use one os for now --- .../workflows/test-cli-plugin-manifest.yaml | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index a65eb391..4a3dc659 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -19,19 +19,19 @@ jobs: - runner: ubuntu-20.04 target: x86_64-unknown-linux-gnu platform: linux-amd64 - - runner: ubuntu-20.04 - target: aarch64-unknown-linux-gnu - linux-packages: gcc-aarch64-linux-gnu - linker: /usr/bin/aarch64-linux-gnu-gcc - platform: linux-arm64 - - runner: macos-latest - target: x86_64-apple-darwin - platform: darwin-amd64 - os: macOS - - runner: macos-latest - target: aarch64-apple-darwin - platform: darwin-arm64 - os: macOS + # - runner: ubuntu-20.04 + # target: aarch64-unknown-linux-gnu + # linux-packages: gcc-aarch64-linux-gnu + # linker: /usr/bin/aarch64-linux-gnu-gcc + # platform: linux-arm64 + # - runner: macos-latest + # target: x86_64-apple-darwin + # platform: darwin-amd64 + # os: macOS + # - runner: macos-latest + # target: aarch64-apple-darwin + # platform: darwin-arm64 + # os: macOS # - runner: windows-latest # platform: windows-amd64 # target: x86_64-pc-windows-msvc @@ -179,4 +179,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: package.tar.gz + path: . retention-days: 1 From db55457d796a5daf17afebaf97c73ad1c2d05072 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 15:06:46 +0530 Subject: [PATCH 27/55] just the configuration --- .github/workflows/test-cli-plugin-manifest.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 4a3dc659..97ed6189 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -173,7 +173,8 @@ jobs: mkdir -p configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml cat configuration/.hasura-connector/connector-metadata.yaml - tar vczf package.tar.gz -C configuration . + cd configuration + tar vczf package.tar.gz -C configuration configuration - name: Upload connector package uses: actions/upload-artifact@v4 From 76ffb5f5041caf6c6004eb2f00004efe603d2935 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 15:18:19 +0530 Subject: [PATCH 28/55] only configuration --- .github/workflows/test-cli-plugin-manifest.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 97ed6189..4a3dc659 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -173,8 +173,7 @@ jobs: mkdir -p configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml cat configuration/.hasura-connector/connector-metadata.yaml - cd configuration - tar vczf package.tar.gz -C configuration configuration + tar vczf package.tar.gz -C configuration . - name: Upload connector package uses: actions/upload-artifact@v4 From 23d3724b453a9e650eafd46925a0474970c166db Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 15:36:48 +0530 Subject: [PATCH 29/55] fix --- .github/workflows/test-cli-plugin-manifest.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 4a3dc659..64b22ffc 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -170,10 +170,11 @@ jobs: - name: generate a connector package run: | chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver - mkdir -p configuration + mkdir -p metadata-configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml - cat configuration/.hasura-connector/connector-metadata.yaml - tar vczf package.tar.gz -C configuration . + cat metadata-configuration/.hasura-connector/connector-metadata.yaml + ls metadata-configuration + tar -vczf package.tar.gz -C metadata-configuration . - name: Upload connector package uses: actions/upload-artifact@v4 From 675cf5e9732232a2db5197ee03c4cec83a19c830 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 15:39:33 +0530 Subject: [PATCH 30/55] fix --- .github/workflows/test-cli-plugin-manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 64b22ffc..b05fd450 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -171,7 +171,7 @@ jobs: run: | chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration - ./cli/linux-amd64/hasura-ndc-sqlserver --context=configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml cat metadata-configuration/.hasura-connector/connector-metadata.yaml ls metadata-configuration tar -vczf package.tar.gz -C metadata-configuration . From 8682e91f8556c4af019f62a3050d6ae7020e68f5 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 15:45:22 +0530 Subject: [PATCH 31/55] fix the path --- .github/workflows/test-cli-plugin-manifest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index b05fd450..9b875da2 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -180,5 +180,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: package.tar.gz - path: . + path: package.tar.gz retention-days: 1 From c8f9b28c415f578455dcdbac12d5521eca75d556 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 16:07:36 +0530 Subject: [PATCH 32/55] create tar ball of the binaries --- .../workflows/test-cli-plugin-manifest.yaml | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml index 9b875da2..3f134090 100644 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ b/.github/workflows/test-cli-plugin-manifest.yaml @@ -129,6 +129,13 @@ jobs: bin: "${{matrix.platform}}/hasura-ndc-sqlserver${{ matrix.extension }}" EOF + - name: Package binaries + uses: actions/upload-artifact@v4 + with: + name: cli-binaries + path: cli/ + retention-days: 1 + - name: Upload manifest entry uses: actions/upload-artifact@v4 with: @@ -144,6 +151,29 @@ jobs: path: cli/${{ matrix.platform }}/hasura-ndc-sqlserver retention-days: 1 + + # Add a new job after build-cli-binaries: + create-cli-package: + needs: build-cli-binaries + runs-on: ubuntu-latest + steps: + - name: Download binaries + uses: actions/download-artifact@v4 + with: + name: cli-binaries + path: cli/ + + - name: Create tarball + run: tar -czf cli.tar.gz -C cli . + + - name: Upload CLI package + uses: actions/upload-artifact@v4 + with: + name: cli.tar.gz + path: cli.tar.gz + retention-days: 1 + + create-manifest: needs: build-cli-binaries runs-on: ubuntu-latest From 3b7db4c50a85ea6cf15b172fab2d46c1492bc851 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 16:25:37 +0530 Subject: [PATCH 33/55] update the ship job --- .github/workflows/ship.yaml | 116 +++++++++++++++++++++++++++++++++--- 1 file changed, 107 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 125a4a50..7d924daa 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -122,16 +122,23 @@ jobs: include: - runner: ubuntu-20.04 target: x86_64-unknown-linux-gnu + platform: linux-amd64 - runner: ubuntu-20.04 target: aarch64-unknown-linux-gnu + platform: linux-arm64 linux-packages: gcc-aarch64-linux-gnu linker: /usr/bin/aarch64-linux-gnu-gcc - runner: macos-latest target: x86_64-apple-darwin + platform: darwin-amd64 + os: macOS - runner: macos-latest target: aarch64-apple-darwin + platform: darwin-arm64 + os: macOS - runner: windows-latest target: x86_64-pc-windows-msvc + platform: windows-amd64 extension: .exe extra-rust-flags: "-C target-feature=+crt-static" runs-on: ${{ matrix.runner }} @@ -200,8 +207,49 @@ jobs: echo "Building for target: ${CARGO_BUILD_TARGET}" cargo build --release --bin ndc-sqlserver-cli - mkdir -p release - mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli release/ndc-sqlserver-cli-${{ matrix.target }}${{ matrix.extension }} + # Create platform-specific directory under cli/ + mkdir -p cli/${{ matrix.platform }} + + # Move the binary with the correct name + if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then + mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli${{ matrix.extension }} cli/${{ matrix.platform }}/hasura-ndc-sqlserver.exe + else + mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli cli/${{ matrix.platform }}/hasura-ndc-sqlserver + fi + + - name: Generate manifest entry + shell: bash + run: | + + # Calculate SHA256 of the binary + if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then + SHA256=$(certutil -hashfile cli/${{ matrix.platform }}/hasura-ndc-sqlserver.exe SHA256 | grep -v "hash" | awk '{print $1}') + elif [[ "${{ matrix.os }}" == "macOS" ]]; then + SHA256=$(shasum -a 256 cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) + else + SHA256=$(sha256sum cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) + fi + + cat << EOF > manifest-entry.yaml + - selector: ${{ matrix.platform }} + uri: "https://github.com/${{ github.repository }}/releases/download/v2.0.0-test/cli.tar.gz" + sha256: "${SHA256}" + bin: "${{matrix.platform}}/hasura-ndc-sqlserver${{ matrix.extension }}" + EOF + + - name: Package binaries + uses: actions/upload-artifact@v4 + with: + name: cli-binaries + path: cli/ + retention-days: 1 + if-no-files-found: error + + - uses: actions/upload-artifact@v4 + with: + name: cli-${{ matrix.platform }} + path: cli + if-no-files-found: error - uses: actions/upload-artifact@v4 with: @@ -209,6 +257,45 @@ jobs: path: release if-no-files-found: error + - name: Upload manifest entry + uses: actions/upload-artifact@v4 + with: + name: manifest-${{ matrix.platform }} + path: manifest-entry.yaml + retention-days: 1 + + + - name: Upload linux-amd64 binary + uses: actions/upload-artifact@v4 + if: matrix.platform == 'linux-amd64' + with: + name: linux-binary + path: cli/${{ matrix.platform }}/hasura-ndc-sqlserver + retention-days: 1 + + + # Add a new job after build-cli-binaries: + create-cli-package: + needs: build-cli-binaries + runs-on: ubuntu-latest + steps: + - name: Download binaries + uses: actions/download-artifact@v4 + with: + name: cli-binaries + path: cli/ + + - name: Create tarball + run: tar -czf cli.tar.gz -C cli . + + - name: Upload CLI package + uses: actions/upload-artifact@v4 + with: + name: cli.tar.gz + path: cli.tar.gz + retention-days: 1 + + release: name: release to GitHub needs: @@ -225,10 +312,11 @@ jobs: path: release/artifacts merge-multiple: true - - name: generate SHA-256 checksums - run: | - cd release/artifacts - sha256sum * > ./sha256sum + - name: Download linux binary + uses: actions/download-artifact@v4 + with: + name: linux-binary + path: cli/linux-amd64 - name: generate a changelog run: | @@ -236,9 +324,19 @@ jobs: - name: generate a connector package run: | - chmod +x ./release/artifacts/ndc-sqlserver-cli-* - ./release/artifacts/ndc-sqlserver-cli-x86_64-unknown-linux-gnu --context=release/package initialize --with-metadata - tar vczf release/artifacts/package.tar.gz -C release/package . + chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver + mkdir -p metadata-configuration + ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + cat metadata-configuration/.hasura-connector/connector-metadata.yaml + ls metadata-configuration + tar -vczf package.tar.gz -C metadata-configuration . + + + - name: generate a connector package + run: | + chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver + ./cli/linux-amd64/hasura-ndc-sqlserver --context=release/package initialize --with-metadata + tar vczf release/artifacts/package.tar.gz -C configuration . - name: create a draft release uses: ncipollo/release-action@v1 From fe64ef7c1fc1fd4ae19de45709e07613f466fa91 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 16:39:15 +0530 Subject: [PATCH 34/55] correct mistakes --- .github/workflows/ship.yaml | 62 +++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 7d924daa..06b8187f 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -237,26 +237,6 @@ jobs: bin: "${{matrix.platform}}/hasura-ndc-sqlserver${{ matrix.extension }}" EOF - - name: Package binaries - uses: actions/upload-artifact@v4 - with: - name: cli-binaries - path: cli/ - retention-days: 1 - if-no-files-found: error - - - uses: actions/upload-artifact@v4 - with: - name: cli-${{ matrix.platform }} - path: cli - if-no-files-found: error - - - uses: actions/upload-artifact@v4 - with: - name: ndc-sqlserver-cli-${{ matrix.target }} - path: release - if-no-files-found: error - - name: Upload manifest entry uses: actions/upload-artifact@v4 with: @@ -264,35 +244,49 @@ jobs: path: manifest-entry.yaml retention-days: 1 - - - name: Upload linux-amd64 binary + - name: Upload binary uses: actions/upload-artifact@v4 - if: matrix.platform == 'linux-amd64' with: - name: linux-binary - path: cli/${{ matrix.platform }}/hasura-ndc-sqlserver + name: cli-binaries + path: cli/${{ matrix.platform }} retention-days: 1 - - # Add a new job after build-cli-binaries: create-cli-package: needs: build-cli-binaries runs-on: ubuntu-latest steps: - - name: Download binaries + - name: Download all binaries uses: actions/download-artifact@v4 with: name: cli-binaries - path: cli/ + path: cli - name: Create tarball - run: tar -czf cli.tar.gz -C cli . + run: | + tar -czf cli.tar.gz -C cli . + echo "Created cli.tar.gz containing:" + tar -tvf cli.tar.gz + + - name: Download manifest entries + uses: actions/download-artifact@v4 + with: + path: entries + + - name: Combine manifest entries + run: | + # Combine all yaml entries into a single file + find entries -name "manifest-entry.yaml" -exec cat {} \; > cli-manifest.yaml + + echo "Generated CLI Plugin Manifest:" + cat cli-manifest.yaml - - name: Upload CLI package + - name: Upload CLI package and manifest uses: actions/upload-artifact@v4 with: - name: cli.tar.gz - path: cli.tar.gz + name: release-artifacts + path: | + cli.tar.gz + cli-manifest.yaml retention-days: 1 @@ -315,7 +309,7 @@ jobs: - name: Download linux binary uses: actions/download-artifact@v4 with: - name: linux-binary + name: linux-amd64/hasura-ndc-sqlserver path: cli/linux-amd64 - name: generate a changelog From 9d63db867ba188ed8c9ec39e8c09b14be909df2b Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 16:50:18 +0530 Subject: [PATCH 35/55] modify ship.yaml --- .github/workflows/ship.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 06b8187f..3954242d 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -247,7 +247,7 @@ jobs: - name: Upload binary uses: actions/upload-artifact@v4 with: - name: cli-binaries + name: cli-binary-${{ matrix.platform }} path: cli/${{ matrix.platform }} retention-days: 1 @@ -258,8 +258,9 @@ jobs: - name: Download all binaries uses: actions/download-artifact@v4 with: - name: cli-binaries + name: cli-binary-* path: cli + merge-multiple: true - name: Create tarball run: | From 1e016591777611b0add89f78a86107dc87e8b076 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 16:56:57 +0530 Subject: [PATCH 36/55] use pattern instead of name --- .github/workflows/ship.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 3954242d..fe988313 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -258,7 +258,7 @@ jobs: - name: Download all binaries uses: actions/download-artifact@v4 with: - name: cli-binary-* + pattern: cli-binary-* path: cli merge-multiple: true From 3ede7b0ff81d1aa1124a8821eb2524cc650ec525 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 17:06:20 +0530 Subject: [PATCH 37/55] use separate-directories true --- .github/workflows/ship.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index fe988313..2aa6e481 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -260,7 +260,7 @@ jobs: with: pattern: cli-binary-* path: cli - merge-multiple: true + seperate-directories: true - name: Create tarball run: | From bc4ea2072e77418b6f5ac44a983354d28d6ffef0 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:03:24 +0530 Subject: [PATCH 38/55] update the connector-manifest --- .github/workflows/ship.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 2aa6e481..d2585fda 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -234,7 +234,7 @@ jobs: - selector: ${{ matrix.platform }} uri: "https://github.com/${{ github.repository }}/releases/download/v2.0.0-test/cli.tar.gz" sha256: "${SHA256}" - bin: "${{matrix.platform}}/hasura-ndc-sqlserver${{ matrix.extension }}" + bin: "cli-binary-${{matrix.platform}}/hasura-ndc-sqlserver${{ matrix.extension }}" EOF - name: Upload manifest entry @@ -260,7 +260,6 @@ jobs: with: pattern: cli-binary-* path: cli - seperate-directories: true - name: Create tarball run: | From 0316f57932e95a8e081a85712b5a05fa4e41ed2c Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:15:18 +0530 Subject: [PATCH 39/55] run the release always --- .github/workflows/ship.yaml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index d2585fda..b2f379b6 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -297,7 +297,7 @@ jobs: - build-cli-binaries runs-on: ubuntu-latest # We release when a tag is pushed. - if: startsWith(github.ref, 'refs/tags/v') + # if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v4 @@ -318,7 +318,7 @@ jobs: - name: generate a connector package run: | - chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver + chmod +x ./cli/cli-binarylinux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml cat metadata-configuration/.hasura-connector/connector-metadata.yaml @@ -328,13 +328,18 @@ jobs: - name: generate a connector package run: | - chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver + chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver ./cli/linux-amd64/hasura-ndc-sqlserver --context=release/package initialize --with-metadata tar vczf release/artifacts/package.tar.gz -C configuration . - - name: create a draft release - uses: ncipollo/release-action@v1 + - name: upload artifact + uses: actions/upload-artifact@v4 with: - draft: true - bodyFile: release/notes.md - artifacts: release/artifacts/* + name: release-artifacts + + # - name: create a draft release + # uses: ncipollo/release-action@v1 + # with: + # draft: true + # bodyFile: release/notes.md + # artifacts: release/artifacts/* From 24f1e54398f1b9571518289697ed2ac140f0375e Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:24:57 +0530 Subject: [PATCH 40/55] uncomment the draft release --- .github/workflows/ship.yaml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index b2f379b6..2cfc35d7 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -332,14 +332,9 @@ jobs: ./cli/linux-amd64/hasura-ndc-sqlserver --context=release/package initialize --with-metadata tar vczf release/artifacts/package.tar.gz -C configuration . - - name: upload artifact - uses: actions/upload-artifact@v4 + - name: create a draft release + uses: ncipollo/release-action@v1 with: - name: release-artifacts - - # - name: create a draft release - # uses: ncipollo/release-action@v1 - # with: - # draft: true - # bodyFile: release/notes.md - # artifacts: release/artifacts/* + draft: true + bodyFile: release/notes.md + artifacts: release/artifacts/* From 66848a83480e0ff7544c281db2235ac45069803f Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:32:20 +0530 Subject: [PATCH 41/55] unblock release to github --- .github/workflows/ship.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 2cfc35d7..1af2a6ff 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -54,7 +54,7 @@ jobs: # Only run on the `main` branch or version tags. # Note we currently tag the image with 'latest', so will want to stop doing # so if we run this on PR branches, etc. - if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) + # if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) permissions: contents: read id-token: write From c4a2a7a8554a9092b63e54404152e9067cfdaa12 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:34:08 +0530 Subject: [PATCH 42/55] unblock release to github --- .github/workflows/ship.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 1af2a6ff..e85c651b 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -54,7 +54,7 @@ jobs: # Only run on the `main` branch or version tags. # Note we currently tag the image with 'latest', so will want to stop doing # so if we run this on PR branches, etc. - # if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) + if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) permissions: contents: read id-token: write @@ -294,7 +294,7 @@ jobs: name: release to GitHub needs: - push-docker-images # not strictly necessary, but if this fails, we should abort - - build-cli-binaries +# - build-cli-binaries runs-on: ubuntu-latest # We release when a tag is pushed. # if: startsWith(github.ref, 'refs/tags/v') From df037c3eb3ded1d8bb398b8e7f14daeaf27faec6 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:38:18 +0530 Subject: [PATCH 43/55] uncomment the other need --- .github/workflows/ship.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index e85c651b..1a4bf834 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -293,8 +293,8 @@ jobs: release: name: release to GitHub needs: - - push-docker-images # not strictly necessary, but if this fails, we should abort -# - build-cli-binaries +# - push-docker-images # not strictly necessary, but if this fails, we should abort + - build-cli-binaries runs-on: ubuntu-latest # We release when a tag is pushed. # if: startsWith(github.ref, 'refs/tags/v') From c0f48328bb4a8f5ac60546377ff267b2c3f1e840 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:48:17 +0530 Subject: [PATCH 44/55] use path --- .github/workflows/ship.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 1a4bf834..5c92a012 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -303,20 +303,15 @@ jobs: - uses: actions/download-artifact@v4 with: - path: release/artifacts - merge-multiple: true - - - name: Download linux binary - uses: actions/download-artifact@v4 - with: - name: linux-amd64/hasura-ndc-sqlserver - path: cli/linux-amd64 + name: release-artifacts + path: release - name: generate a changelog run: | ./scripts/release-notes.py "${GITHUB_REF_NAME}" >> release/notes.md - name: generate a connector package + path: release/release-artifacts run: | chmod +x ./cli/cli-binarylinux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration @@ -327,6 +322,7 @@ jobs: - name: generate a connector package + path: release/release-artifacts run: | chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver ./cli/linux-amd64/hasura-ndc-sqlserver --context=release/package initialize --with-metadata From d75190ae8164bb1c0b4b81cc9613db59f6be0af7 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:50:57 +0530 Subject: [PATCH 45/55] fix path --- .github/workflows/ship.yaml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 5c92a012..28cd49fb 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -313,20 +313,19 @@ jobs: - name: generate a connector package path: release/release-artifacts run: | - chmod +x ./cli/cli-binarylinux-amd64/hasura-ndc-sqlserver - mkdir -p metadata-configuration - ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml - cat metadata-configuration/.hasura-connector/connector-metadata.yaml - ls metadata-configuration - tar -vczf package.tar.gz -C metadata-configuration . - + chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver + mkdir -p metadata-configuration + ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + cat metadata-configuration/.hasura-connector/connector-metadata.yaml + ls metadata-configuration + tar -vczf package.tar.gz -C metadata-configuration . - name: generate a connector package path: release/release-artifacts run: | - chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver - ./cli/linux-amd64/hasura-ndc-sqlserver --context=release/package initialize --with-metadata - tar vczf release/artifacts/package.tar.gz -C configuration . + chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver + ./cli/linux-amd64/hasura-ndc-sqlserver --context=release/package initialize --with-metadata + tar vczf release/artifacts/package.tar.gz -C configuration . - name: create a draft release uses: ncipollo/release-action@v1 From 36a9b7d34b4873dc0260316e038d659c6e83e6be Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:52:39 +0530 Subject: [PATCH 46/55] fix package --- .github/workflows/ship.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 28cd49fb..b607920c 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -311,8 +311,8 @@ jobs: ./scripts/release-notes.py "${GITHUB_REF_NAME}" >> release/notes.md - name: generate a connector package - path: release/release-artifacts run: | + cd release/release-artifacts chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml @@ -321,8 +321,8 @@ jobs: tar -vczf package.tar.gz -C metadata-configuration . - name: generate a connector package - path: release/release-artifacts run: | + cd release/release-artifacts chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver ./cli/linux-amd64/hasura-ndc-sqlserver --context=release/package initialize --with-metadata tar vczf release/artifacts/package.tar.gz -C configuration . From aacb24ee1f43975ef69c99f2b9078ee13a3b8b58 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 20:57:27 +0530 Subject: [PATCH 47/55] depend on create-cli-package --- .github/workflows/ship.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index b607920c..344feb8a 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -295,6 +295,7 @@ jobs: needs: # - push-docker-images # not strictly necessary, but if this fails, we should abort - build-cli-binaries + - create-cli-package runs-on: ubuntu-latest # We release when a tag is pushed. # if: startsWith(github.ref, 'refs/tags/v') From 38d03148d25e93a105f0826da8dfc306ee158585 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 21:03:12 +0530 Subject: [PATCH 48/55] comment generate changelog --- .github/workflows/ship.yaml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 344feb8a..21c5a95f 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -307,9 +307,9 @@ jobs: name: release-artifacts path: release - - name: generate a changelog - run: | - ./scripts/release-notes.py "${GITHUB_REF_NAME}" >> release/notes.md + # - name: generate a changelog + # run: | + # ./scripts/release-notes.py "${GITHUB_REF_NAME}" >> release/notes.md - name: generate a connector package run: | @@ -321,16 +321,9 @@ jobs: ls metadata-configuration tar -vczf package.tar.gz -C metadata-configuration . - - name: generate a connector package - run: | - cd release/release-artifacts - chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver - ./cli/linux-amd64/hasura-ndc-sqlserver --context=release/package initialize --with-metadata - tar vczf release/artifacts/package.tar.gz -C configuration . - - name: create a draft release uses: ncipollo/release-action@v1 with: draft: true - bodyFile: release/notes.md +# bodyFile: release/notes.md artifacts: release/artifacts/* From e6283db2741abf534dd5ba629a992834b3d2c894 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Thu, 23 Jan 2025 21:14:01 +0530 Subject: [PATCH 49/55] fix release --- .github/workflows/ship.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 21c5a95f..288697a6 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -313,6 +313,8 @@ jobs: - name: generate a connector package run: | + tree . + unzip release/release-artifacts.zip cd release/release-artifacts chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration From d006f80ea7033e63e3e0e70969a4ac4fde552958 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Fri, 24 Jan 2025 12:19:46 +0530 Subject: [PATCH 50/55] untar release/cli.tar.gz --- .github/workflows/ship.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index 288697a6..d95acb51 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -313,9 +313,7 @@ jobs: - name: generate a connector package run: | - tree . - unzip release/release-artifacts.zip - cd release/release-artifacts + tar xvf release/cli.tar.gz -C release/cli chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml From ffe5e7be69fc525ecc3b7ccb0cea34fa49fc29dc Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Fri, 24 Jan 2025 12:23:03 +0530 Subject: [PATCH 51/55] make some changes --- .github/workflows/ship.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index d95acb51..ae5ce80c 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -305,7 +305,7 @@ jobs: - uses: actions/download-artifact@v4 with: name: release-artifacts - path: release + path: release/artifacts # - name: generate a changelog # run: | @@ -313,13 +313,13 @@ jobs: - name: generate a connector package run: | - tar xvf release/cli.tar.gz -C release/cli - chmod +x ./cli/cli-binary-linux-amd64/hasura-ndc-sqlserver + tar xvf release/artifacts/cli.tar.gz -C release/artifacts + chmod +x ./release/artifacts/cli/cli-binary-linux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration - ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml + ./release/artifacts/cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=release/artifacts/cli-manifest.yaml cat metadata-configuration/.hasura-connector/connector-metadata.yaml ls metadata-configuration - tar -vczf package.tar.gz -C metadata-configuration . + tar -vczf release/artifacts/package.tar.gz -C metadata-configuration . - name: create a draft release uses: ncipollo/release-action@v1 From 4aa89ffc9994aceb7970258d75a68e9f0de8bda9 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Fri, 24 Jan 2025 12:36:45 +0530 Subject: [PATCH 52/55] again --- .github/workflows/ship.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index ae5ce80c..b1c686a0 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -314,7 +314,8 @@ jobs: - name: generate a connector package run: | tar xvf release/artifacts/cli.tar.gz -C release/artifacts - chmod +x ./release/artifacts/cli/cli-binary-linux-amd64/hasura-ndc-sqlserver + tree release/artifacts + chmod +x ./release/artifacts/cli-binary-linux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration ./release/artifacts/cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=release/artifacts/cli-manifest.yaml cat metadata-configuration/.hasura-connector/connector-metadata.yaml From ea82d19739c85ab89067f07fee287c43885ec60a Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Fri, 24 Jan 2025 12:43:02 +0530 Subject: [PATCH 53/55] again once more --- .github/workflows/ship.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index b1c686a0..e709de93 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -317,7 +317,7 @@ jobs: tree release/artifacts chmod +x ./release/artifacts/cli-binary-linux-amd64/hasura-ndc-sqlserver mkdir -p metadata-configuration - ./release/artifacts/cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=release/artifacts/cli-manifest.yaml + ./release/artifacts/cli-binary-linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=release/artifacts/cli-manifest.yaml cat metadata-configuration/.hasura-connector/connector-metadata.yaml ls metadata-configuration tar -vczf release/artifacts/package.tar.gz -C metadata-configuration . From 57d82a428a94be310f69f82790b58c9b05485cf8 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Fri, 24 Jan 2025 12:57:48 +0530 Subject: [PATCH 54/55] correct ship --- .github/workflows/ship.yaml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ship.yaml b/.github/workflows/ship.yaml index e709de93..2c45248e 100644 --- a/.github/workflows/ship.yaml +++ b/.github/workflows/ship.yaml @@ -218,6 +218,7 @@ jobs: fi - name: Generate manifest entry + if: startsWith(github.ref, 'refs/tags/v') shell: bash run: | @@ -230,9 +231,12 @@ jobs: SHA256=$(sha256sum cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) fi + # Extract tag from github.ref by removing 'refs/tags/' prefix + TAG=${GITHUB_REF#refs/tags/} + cat << EOF > manifest-entry.yaml - selector: ${{ matrix.platform }} - uri: "https://github.com/${{ github.repository }}/releases/download/v2.0.0-test/cli.tar.gz" + uri: "https://github.com/${{ github.repository }}/releases/download/${TAG}/cli.tar.gz" sha256: "${SHA256}" bin: "cli-binary-${{matrix.platform}}/hasura-ndc-sqlserver${{ matrix.extension }}" EOF @@ -253,6 +257,7 @@ jobs: create-cli-package: needs: build-cli-binaries + if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - name: Download all binaries @@ -293,12 +298,12 @@ jobs: release: name: release to GitHub needs: -# - push-docker-images # not strictly necessary, but if this fails, we should abort + - push-docker-images # not strictly necessary, but if this fails, we should abort - build-cli-binaries - create-cli-package runs-on: ubuntu-latest # We release when a tag is pushed. - # if: startsWith(github.ref, 'refs/tags/v') + if: startsWith(github.ref, 'refs/tags/v') steps: - uses: actions/checkout@v4 @@ -307,9 +312,9 @@ jobs: name: release-artifacts path: release/artifacts - # - name: generate a changelog - # run: | - # ./scripts/release-notes.py "${GITHUB_REF_NAME}" >> release/notes.md + - name: generate a changelog + run: | + ./scripts/release-notes.py "${GITHUB_REF_NAME}" >> release/notes.md - name: generate a connector package run: | @@ -326,5 +331,5 @@ jobs: uses: ncipollo/release-action@v1 with: draft: true -# bodyFile: release/notes.md + bodyFile: release/notes.md artifacts: release/artifacts/* From 40d270c65a9a84554c978147d705d9f268d618c2 Mon Sep 17 00:00:00 2001 From: Karthikeyan C Date: Fri, 24 Jan 2025 13:01:25 +0530 Subject: [PATCH 55/55] remove the test-cli-plugin-manifest file --- .../workflows/test-cli-plugin-manifest.yaml | 214 ------------------ 1 file changed, 214 deletions(-) delete mode 100644 .github/workflows/test-cli-plugin-manifest.yaml diff --git a/.github/workflows/test-cli-plugin-manifest.yaml b/.github/workflows/test-cli-plugin-manifest.yaml deleted file mode 100644 index 3f134090..00000000 --- a/.github/workflows/test-cli-plugin-manifest.yaml +++ /dev/null @@ -1,214 +0,0 @@ -name: Test CLI Plugin Manifest - -on: - workflow_dispatch: - pull_request: - branches: - - main - -env: - CARGO_TERM_COLOR: always - BINARY_NAME: your_cli_name - -jobs: - build-cli-binaries: - name: build the CLI binaries - strategy: - matrix: - include: - - runner: ubuntu-20.04 - target: x86_64-unknown-linux-gnu - platform: linux-amd64 - # - runner: ubuntu-20.04 - # target: aarch64-unknown-linux-gnu - # linux-packages: gcc-aarch64-linux-gnu - # linker: /usr/bin/aarch64-linux-gnu-gcc - # platform: linux-arm64 - # - runner: macos-latest - # target: x86_64-apple-darwin - # platform: darwin-amd64 - # os: macOS - # - runner: macos-latest - # target: aarch64-apple-darwin - # platform: darwin-arm64 - # os: macOS - # - runner: windows-latest - # platform: windows-amd64 - # target: x86_64-pc-windows-msvc - # extension: .exe - # extra-rust-flags: "-C target-feature=+crt-static" - runs-on: ${{ matrix.runner }} - env: - CARGO_BUILD_TARGET: ${{ matrix.target }} - CARGO_NET_GIT_FETCH_WITH_CLI: "true" - RUSTFLAGS: "-D warnings" # fail on warnings - defaults: - run: - shell: bash - steps: - - uses: actions/checkout@v4 - - - name: install protoc - uses: arduino/setup-protoc@v3 - with: - version: "25.x" - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: install tools - run: | - rustup show - rustup target add ${{ matrix.target }} - - - name: install other packages required - if: matrix.linux-packages - run: | - sudo apt-get update - sudo apt-get install -y ${{ matrix.linux-packages }} - - - name: build the CLI - run: | - # If we're on a tag, use the tag name as the release version. - if [[ "$GITHUB_REF_TYPE" == 'tag' ]]; then - # Ensure that the version specified in Cargo.toml is the same as the tag (with a 'v' prefix). - CARGO_VERSION="$(cargo metadata --format-version=1 | jq -r '.packages | .[] | select(.name == "ndc-sqlserver") | .version')" - echo "Git tag: ${GIT_REF_NAME}" - echo "Cargo version: ${CARGO_VERSION}" - - if [[ "$GITHUB_REF_NAME" != "v${CARGO_VERSION}" ]]; then - echo >&2 "The Git tag is \"${GITHUB_REF_NAME}\", but the version in Cargo.toml is \"${CARGO_VERSION}\"." - echo >&2 'These must be the same, with a "v" prefix for the tag. Aborting.' - exit 1 - fi - export RELEASE_VERSION="$GITHUB_REF_NAME" - echo "RELEASE_VERSION = ${RELEASE_VERSION}" - fi - - if [[ -n '${{ matrix.linker }}' ]]; then - TARGET_SCREAMING="$(echo '${{ matrix.target }}' | tr '[:lower:]' '[:upper:]' | tr '-' '_')" - echo "CARGO_TARGET_${TARGET_SCREAMING}_LINKER"='${{ matrix.linker }}' - declare "CARGO_TARGET_${TARGET_SCREAMING}_LINKER"='${{ matrix.linker }}' - export "CARGO_TARGET_${TARGET_SCREAMING}_LINKER" - fi - - if [[ -n '${{ matrix.extra-rust-flags }}' ]]; then - RUSTFLAGS="${RUSTFLAGS} ${{ matrix.extra-rust-flags }}" - export RUSTFLAGS - fi - echo "RUSTFLAGS = ${RUSTFLAGS}" - - echo "Building for target: ${CARGO_BUILD_TARGET}" - cargo build --release --bin ndc-sqlserver-cli - - # Create platform-specific directory under cli/ - mkdir -p cli/${{ matrix.platform }} - - # Move the binary with the correct name - if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then - mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli${{ matrix.extension }} cli/${{ matrix.platform }}/hasura-ndc-sqlserver.exe - else - mv -v target/${{ matrix.target }}/release/ndc-sqlserver-cli cli/${{ matrix.platform }}/hasura-ndc-sqlserver - fi - - - name: Generate manifest entry - shell: bash - run: | - - # Calculate SHA256 of the binary - if [[ "${{ matrix.platform }}" == "windows-amd64" ]]; then - SHA256=$(certutil -hashfile cli/${{ matrix.platform }}/hasura-ndc-sqlserver.exe SHA256 | grep -v "hash" | awk '{print $1}') - elif [[ "${{ matrix.os }}" == "macOS" ]]; then - SHA256=$(shasum -a 256 cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) - else - SHA256=$(sha256sum cli/${{ matrix.platform }}/hasura-ndc-sqlserver | cut -d' ' -f1) - fi - - cat << EOF > manifest-entry.yaml - - selector: ${{ matrix.platform }} - uri: "https://github.com/${{ github.repository }}/releases/download/v2.0.0-test/cli.tar.gz" - sha256: "${SHA256}" - bin: "${{matrix.platform}}/hasura-ndc-sqlserver${{ matrix.extension }}" - EOF - - - name: Package binaries - uses: actions/upload-artifact@v4 - with: - name: cli-binaries - path: cli/ - retention-days: 1 - - - name: Upload manifest entry - uses: actions/upload-artifact@v4 - with: - name: manifest-${{ matrix.platform }} - path: manifest-entry.yaml - retention-days: 1 - - - name: Upload linux-amd64 binary - uses: actions/upload-artifact@v4 - if: matrix.platform == 'linux-amd64' - with: - name: linux-binary - path: cli/${{ matrix.platform }}/hasura-ndc-sqlserver - retention-days: 1 - - - # Add a new job after build-cli-binaries: - create-cli-package: - needs: build-cli-binaries - runs-on: ubuntu-latest - steps: - - name: Download binaries - uses: actions/download-artifact@v4 - with: - name: cli-binaries - path: cli/ - - - name: Create tarball - run: tar -czf cli.tar.gz -C cli . - - - name: Upload CLI package - uses: actions/upload-artifact@v4 - with: - name: cli.tar.gz - path: cli.tar.gz - retention-days: 1 - - - create-manifest: - needs: build-cli-binaries - runs-on: ubuntu-latest - steps: - - name: Download all manifest entries - uses: actions/download-artifact@v4 - with: - path: entries - - - name: Download linux binary - uses: actions/download-artifact@v4 - with: - name: linux-binary - path: cli/linux-amd64 - - - name: Combine manifest entries - run: | - # Combine all yaml entries into a single file - find entries -name "manifest-entry.yaml" -exec cat {} \; > cli-manifest.yaml - - echo "Generated CLI Plugin Manifest:" - cat cli-manifest.yaml - - - name: generate a connector package - run: | - chmod +x ./cli/linux-amd64/hasura-ndc-sqlserver - mkdir -p metadata-configuration - ./cli/linux-amd64/hasura-ndc-sqlserver --context=metadata-configuration initialize --with-metadata --binary-cli-manifest=cli-manifest.yaml - cat metadata-configuration/.hasura-connector/connector-metadata.yaml - ls metadata-configuration - tar -vczf package.tar.gz -C metadata-configuration . - - - name: Upload connector package - uses: actions/upload-artifact@v4 - with: - name: package.tar.gz - path: package.tar.gz - retention-days: 1