diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 06ead23..66a3ac4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -26,6 +26,9 @@ jobs: permissions: contents: read packages: write + outputs: + commit_hash: ${{ steps.get_commit_hash.outputs.commit_hash }} + sha256: ${{ steps.calculate_checksum.outputs.sha256 }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -43,7 +46,7 @@ jobs: with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.PAT_TOKEN }} # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. - name: Extract metadata (tags, labels) for Docker id: meta @@ -73,6 +76,18 @@ jobs: path: ./connector-definition/dist/connector-definition.tgz compression-level: 0 # Already compressed + - name: Calculate SHA256 checksum + id: calculate_checksum + run: | + SHA256=$(sha256sum ./connector-definition/dist/connector-definition.tgz | awk '{ print $1 }') + echo "sha256=$SHA256" >> $GITHUB_OUTPUT + + - name: Get commit hash + id: get_commit_hash + run: | + COMMIT_HASH=$(git rev-parse HEAD) + echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT + release-connector: name: Release connector runs-on: ubuntu-latest @@ -101,4 +116,66 @@ jobs: body: ${{ steps.changelog-reader.outputs.changes }} files: | ./connector-definition/dist/connector-definition.tgz - fail_on_unmatched_files: true \ No newline at end of file + fail_on_unmatched_files: true + + - name: Update ndc-hub + env: + CONNECTOR_NAME: qdrant + COMMIT_HASH: ${{ needs.build-and-push-image.outputs.commit_hash }} + SHA256: ${{ needs.build-and-push-image.outputs.sha256 }} + GH_TOKEN: ${{ secrets.PAT_TOKEN }} + run: | + # Clone ndc-hub repository + git clone https://github.com/hasura/ndc-hub.git + cd ndc-hub + + # Create a new branch + NEW_BRANCH="update-${{ env.CONNECTOR_NAME }}-connector-v${{ steps.get-version.outputs.tagged_version }}" + git checkout -b $NEW_BRANCH + + cd registry/${{ env.CONNECTOR_NAME }} + + # Update metadata.json + jq --arg version "${{ steps.get-version.outputs.tagged_version }}" \ + --arg version_tag "v${{ steps.get-version.outputs.tagged_version }}" \ + --arg uri "https://github.com/${{ github.repository }}/releases/download/v${{ steps.get-version.outputs.tagged_version }}/connector-definition.tgz" \ + --arg checksum "$SHA256" \ + --arg commit_hash "$COMMIT_HASH" \ + '.overview.latest_version = $version_tag | + .packages += [{ + "version": $version, + "uri": $uri, + "checksum": { + "type": "sha256", + "value": $checksum + }, + "source": { + "hash": $commit_hash + } + }] | + .source_code.version += [{ + "tag": $version_tag, + "hash": $commit_hash, + "is_verified": false + }]' \ + metadata.json > tmp.json && mv tmp.json metadata.json + + cp ../../../README.md ./README.md + + # Commit changes + git config user.name "GitHub Action" + git config user.email "action@github.com" + git add metadata.json README.md + git commit -m "Update ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}" + + # Push changes + git push https://${{ secrets.PAT_TOKEN }}@github.com/hasura/ndc-hub.git HEAD:update-${{ env.CONNECTOR_NAME }}-connector-v${{ steps.get-version.outputs.tagged_version }} + + + # Create PR using GitHub CLI + cd ../.. + gh pr create --repo hasura/ndc-hub \ + --base main \ + --head $NEW_BRANCH \ + --title "Update ${{ env.CONNECTOR_NAME }} connector to v${{ steps.get-version.outputs.tagged_version }}" \ + --body "This PR updates the ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}." \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fb25e9c..a0b7623 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Qdrant Connector Changelog This changelog documents changes between release tags. +## [0.2.3] - 2024-08-06 +* Update workflow to open a PR in ndc-hub + ## [0.2.2] - 2024-08-05 * Update SDK to 5.2.0 * Pin version to 0.1.5 diff --git a/package-lock.json b/package-lock.json index a7c6513..15b09c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ndc-qdrant", - "version": "0.2.2", + "version": "0.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ndc-qdrant", - "version": "0.2.2", + "version": "0.2.3", "dependencies": { "@hasura/ndc-sdk-typescript": "^5.2.0", "@qdrant/js-client-rest": "^1.5.0" diff --git a/package.json b/package.json index a27eeec..5cc1574 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ndc-qdrant", - "version": "0.2.2", + "version": "0.2.3", "main": "index.js", "scripts": { "start": "ts-node ./src/index.ts serve --configuration=.",