Dynamic connections from request_arguments (#87) #22
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release JVM Connectors | |
on: | |
push: | |
tags: | |
- "mysql/v*" | |
- "oracle/v*" | |
- "trino/v*" | |
- "snowflake/v*" | |
jobs: | |
build-connector: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract connector and version | |
id: version | |
run: | | |
TAG=${{ github.ref_name }} | |
CONNECTOR=$(echo $TAG | cut -d'/' -f1) | |
VERSION=$(echo $TAG | cut -d'/' -f2 | sed 's/v//') | |
echo "connector=$CONNECTOR" >> $GITHUB_OUTPUT | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push connector docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ndc-connector-${{ steps.version.outputs.connector }}.dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ghcr.io/hasura/ndc-jvm-${{ steps.version.outputs.connector }}:v${{ steps.version.outputs.version }} | |
build-args: | | |
JOOQ_PRO_EMAIL=${{ secrets.JOOQ_PRO_EMAIL }} | |
JOOQ_PRO_LICENSE=${{ secrets.JOOQ_PRO_LICENSE }} | |
build-cli: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract connector and version | |
id: version | |
run: | | |
TAG=${{ github.ref_name }} | |
CONNECTOR=$(echo $TAG | cut -d'/' -f1) | |
VERSION=$(echo $TAG | cut -d'/' -f2 | sed 's/v//') | |
echo "connector=$CONNECTOR" >> $GITHUB_OUTPUT | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push CLI docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./ndc-cli.dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ghcr.io/hasura/ndc-jvm-cli:v${{ steps.version.outputs.version }}-${{ steps.version.outputs.connector }} | |
build-args: | | |
JOOQ_PRO_EMAIL=${{ secrets.JOOQ_PRO_EMAIL }} | |
JOOQ_PRO_LICENSE=${{ secrets.JOOQ_PRO_LICENSE }} | |
release: | |
runs-on: ubuntu-latest | |
needs: | |
- build-cli | |
- build-connector | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract connector and version | |
id: version | |
run: | | |
TAG=${{ github.ref_name }} | |
CONNECTOR=$(echo $TAG | cut -d'/' -f1) | |
VERSION=$(echo $TAG | cut -d'/' -f2 | sed 's/v//') | |
echo "connector=$CONNECTOR" >> $GITHUB_OUTPUT | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Create connector metadata package | |
run: | | |
# Create directory structure | |
mkdir -p .hasura-connector | |
# Handle specific connector configurations | |
if [[ "${{ steps.version.outputs.connector }}" == "mysql" ]]; then | |
# MySQL-specific configuration with FULLY_QUALIFY_NAMES only | |
SCHEMA_ENV_VAR=" | |
- name: FULLY_QUALIFY_NAMES | |
description: \"Whether to fully qualify table names in the generated configuration, e.g., \`schema.table\` rather than \`table\`\" | |
defaultValue: \"false\"" | |
UPDATE_ARGS="--database, MYSQL, --fully-qualify-names=\$FULLY_QUALIFY_NAMES" | |
BASH_UPDATE_ARGS=" --database MYSQL \\ | |
--fully-qualify-names=\$FULLY_QUALIFY_NAMES \\" | |
POWERSHELL_UPDATE_ARGS=" --database MYSQL \` | |
--fully-qualify-names=\$env:FULLY_QUALIFY_NAMES \`" | |
elif [[ "${{ steps.version.outputs.connector }}" == "snowflake" ]]; then | |
# Snowflake supports both schemas and fully-qualified names | |
SCHEMA_ENV_VAR=" | |
- name: JDBC_SCHEMAS | |
description: \"A comma-separated list of schemas to include in the metadata\" | |
- name: FULLY_QUALIFY_NAMES | |
description: \"Whether to fully qualify table names in the generated configuration, e.g., \`schema.table\` rather than \`table\`\" | |
defaultValue: \"false\"" | |
UPDATE_ARGS="--database, SNOWFLAKE, --schemas, \$JDBC_SCHEMAS, --fully-qualify-names=\$FULLY_QUALIFY_NAMES" | |
BASH_UPDATE_ARGS=" --database SNOWFLAKE \\ | |
--schemas \$JDBC_SCHEMAS \\ | |
--fully-qualify-names=\$FULLY_QUALIFY_NAMES \\" | |
POWERSHELL_UPDATE_ARGS=" --database SNOWFLAKE \` | |
--schemas \$env:JDBC_SCHEMAS \` | |
--fully-qualify-names=\$env:FULLY_QUALIFY_NAMES \`" | |
elif [[ "${{ steps.version.outputs.connector }}" == "oracle" ]]; then | |
# Oracle-specific configuration | |
SCHEMA_ENV_VAR=" | |
- name: JDBC_SCHEMAS | |
description: \"A comma-separated list of schemas to include in the metadata\"" | |
UPDATE_ARGS="--database, ORACLE, --schemas, \$JDBC_SCHEMAS" | |
BASH_UPDATE_ARGS=" --database ORACLE \\ | |
--schemas \$JDBC_SCHEMAS \\" | |
POWERSHELL_UPDATE_ARGS=" --database ORACLE \` | |
--schemas \$env:JDBC_SCHEMAS \`" | |
elif [[ "${{ steps.version.outputs.connector }}" == "trino" ]]; then | |
# Trino-specific configuration | |
SCHEMA_ENV_VAR=" | |
- name: JDBC_SCHEMAS | |
description: \"A comma-separated list of schemas to include in the metadata\"" | |
UPDATE_ARGS="--database, TRINO, --schemas, \$JDBC_SCHEMAS" | |
BASH_UPDATE_ARGS=" --database TRINO \\ | |
--schemas \$JDBC_SCHEMAS \\" | |
POWERSHELL_UPDATE_ARGS=" --database TRINO \` | |
--schemas \$env:JDBC_SCHEMAS \`" | |
fi | |
# Create the connector metadata file with version v1 | |
cat > .hasura-connector/connector-metadata.yaml << EOF | |
version: v1 | |
packagingDefinition: | |
type: PrebuiltDockerImage | |
dockerImage: "ghcr.io/hasura/ndc-jvm-${{ steps.version.outputs.connector }}:v${{ steps.version.outputs.version }}" | |
supportedEnvironmentVariables: | |
- name: JDBC_URL | |
description: "The JDBC URL to connect to the database"${SCHEMA_ENV_VAR} | |
cliPlugin: | |
type: Docker | |
dockerImage: ghcr.io/hasura/ndc-jvm-cli:v${{ steps.version.outputs.version }}-${{ steps.version.outputs.connector }} | |
commands: | |
update: | |
type: Dockerized | |
dockerImage: ghcr.io/hasura/ndc-jvm-cli:v${{ steps.version.outputs.version }}-${{ steps.version.outputs.connector }} | |
commandArgs: [update, ${UPDATE_ARGS}, --outfile, /etc/connector/configuration.json] | |
nativeToolchainDefinition: | |
commands: | |
start: | |
type: ShellScript | |
bash: | | |
#!/usr/bin/env bash | |
set -eu -o pipefail | |
HASURA_CONFIGURATION_DIRECTORY="\$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH" \\ | |
java -Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=\$HASURA_CONNECTOR_PORT -Djava.util.logging.manager=org.jboss.logmanager.LogManager \\ | |
-jar "\$HASURA_DDN_NATIVE_CONNECTOR_DIR/quarkus-run.jar" | |
powershell: | | |
\$ErrorActionPreference = "Stop" | |
\$env:HASURA_CONFIGURATION_DIRECTORY="\$env:HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH"; | |
java \` | |
-Dquarkus.http.host=0.0.0.0 \` | |
-Dquarkus.http.port=\$env:HASURA_CONNECTOR_PORT \` | |
-Djava.util.logging.manager=org.jboss.logmanager.LogManager \` | |
-jar "\$env:HASURA_DDN_NATIVE_CONNECTOR_DIR\\quarkus-run.jar" | |
update: | |
type: ShellScript | |
bash: | | |
#!/usr/bin/env bash | |
set -e -o pipefail | |
"\$HASURA_DDN_NATIVE_CONNECTOR_PLUGIN_DIR/bin/ndc-cli" update \\ | |
${BASH_UPDATE_ARGS} | |
--outfile "\$HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH/configuration.json" | |
powershell: | | |
\$ErrorActionPreference = "Stop" | |
& "\$env:HASURA_DDN_NATIVE_CONNECTOR_PLUGIN_DIR\\bin\\ndc-cli.exe" update \` | |
${POWERSHELL_UPDATE_ARGS} | |
--outfile "\$env:HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH\\configuration.json" | |
watch: | |
type: ShellScript | |
bash: | | |
#!/usr/bin/env bash | |
echo "Watch is not supported for this connector" | |
exit 1 | |
powershell: | | |
Write-Output "Watch is not supported for this connector" | |
exit 1 | |
cliPluginEntrypoint: | |
type: ShellScript | |
bash: 'set -e -o pipefail; "\$HASURA_DDN_NATIVE_CONNECTOR_PLUGIN_DIR/bin/ndc-cli"' | |
powershell: '\$ErrorActionPreference = "Stop"; & "\$env:HASURA_DDN_NATIVE_CONNECTOR_PLUGIN_DIR\bin\ndc-cli.exe"' | |
EOF | |
# Create tarball | |
tar -czf ${{ steps.version.outputs.connector }}-connector-v${{ steps.version.outputs.version }}.tar.gz .hasura-connector/ | |
- name: Calculate checksum | |
id: checksum | |
run: | | |
CHECKSUM=$(sha256sum ${{ steps.version.outputs.connector }}-connector-v${{ steps.version.outputs.version }}.tar.gz | cut -d ' ' -f 1) | |
echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT | |
- name: Generate package metadata | |
id: package-metadata | |
run: | | |
# Get current commit hash | |
COMMIT_HASH=$(git rev-parse HEAD) | |
# Create the connector-packaging.json file | |
cat > connector-packaging.json << EOF | |
{ | |
"version": "v${{ steps.version.outputs.version }}", | |
"uri": "https://github.com/hasura/ndc-jvm-mono/releases/download/${{ steps.version.outputs.connector }}%2Fv${{ steps.version.outputs.version }}/${{ steps.version.outputs.connector }}-connector-v${{ steps.version.outputs.version }}.tar.gz", | |
"checksum": { | |
"type": "sha256", | |
"value": "${{ steps.checksum.outputs.checksum }}" | |
}, | |
"source": { | |
"hash": "$COMMIT_HASH" | |
}, | |
"test": { | |
"test_config_path": "../../tests/tests-config.json" | |
} | |
} | |
EOF | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: "${{ steps.version.outputs.connector }} v${{ steps.version.outputs.version }}" | |
generate_release_notes: true | |
files: | | |
${{ steps.version.outputs.connector }}-connector-v${{ steps.version.outputs.version }}.tar.gz | |
connector-packaging.json |