39
39
build-connector :
40
40
name : Build connector
41
41
runs-on : ubuntu-latest
42
+ outputs :
43
+ commit_hash : ${{ steps.get_commit_hash.outputs.commit_hash }}
44
+ sha256 : ${{ steps.calculate_checksum.outputs.sha256 }}
42
45
steps :
43
46
- uses : actions/checkout@v4
44
47
with :
50
53
run : |
51
54
cd connector-definition
52
55
make build
56
+ - name : Calculate SHA256 checksum
57
+ id : calculate_checksum
58
+ run : |
59
+ SHA256=$(sha256sum ./connector-definition/dist/connector-definition.tgz | awk '{ print $1 }')
60
+ echo "sha256=$SHA256" >> $GITHUB_OUTPUT
61
+ - name : Get commit hash
62
+ id : get_commit_hash
63
+ run : |
64
+ COMMIT_HASH=$(git rev-parse HEAD)
65
+ echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
53
66
- name : Debug information
54
67
run : |
55
68
echo "Contents of connector-definition/dist:"
@@ -69,13 +82,10 @@ jobs:
69
82
if : startsWith(github.ref, 'refs/tags/v')
70
83
steps :
71
84
- uses : actions/checkout@v4
72
-
73
85
- name : Set up QEMU
74
86
uses : docker/setup-qemu-action@v2
75
-
76
87
- name : Set up Docker Buildx
77
88
uses : docker/setup-buildx-action@v3
78
-
79
89
- name : Login to GitHub Container Registry
80
90
uses : docker/login-action@v3
81
91
with :
@@ -128,4 +138,79 @@ jobs:
128
138
body : ${{ steps.changelog-reader.outputs.changes }}
129
139
files : |
130
140
./connector-definition/dist/connector-definition.tgz
131
- fail_on_unmatched_files : true
141
+ fail_on_unmatched_files : true
142
+
143
+ - name : Update ndc-hub
144
+ env :
145
+ REGISTRY_NAME : hasura
146
+ CONNECTOR_NAME : ndc-python-lambda
147
+ COMMIT_HASH : ${{ needs.build-connector.outputs.commit_hash }}
148
+ SHA256 : ${{ needs.build-connector.outputs.sha256 }}
149
+ GH_TOKEN : ${{ secrets.PAT_TOKEN }}
150
+ run : |
151
+ # Clone ndc-hub repository
152
+ git clone https://github.com/hasura/ndc-hub.git
153
+ cd ndc-hub
154
+
155
+ # Create a new branch
156
+ NEW_BRANCH="update-${{ env.CONNECTOR_NAME }}-connector-v${{ steps.get-version.outputs.tagged_version }}"
157
+ git checkout -b $NEW_BRANCH
158
+
159
+ cd registry/${{ env.REGISTRY_NAME }}/${{ env.CONNECTOR_NAME }}
160
+
161
+ # Create releases directory if it doesn't exist
162
+ mkdir -p releases/v${{ steps.get-version.outputs.tagged_version }}
163
+
164
+ # Create connector-packaging.json
165
+ cat << EOF > releases/v${{ steps.get-version.outputs.tagged_version }}/connector-packaging.json
166
+ {
167
+ "version": "v${{ steps.get-version.outputs.tagged_version }}",
168
+ "uri": "https://github.com/${{ github.repository }}/releases/download/v${{ steps.get-version.outputs.tagged_version }}/connector-definition.tgz",
169
+ "checksum": {
170
+ "type": "sha256",
171
+ "value": "$SHA256"
172
+ },
173
+ "source": {
174
+ "hash": "$COMMIT_HASH"
175
+ }
176
+ }
177
+ EOF
178
+
179
+ # Update metadata.json to remove 'packages' field if it exists and update 'latest_version'
180
+ jq --arg version_tag "v${{ steps.get-version.outputs.tagged_version }}" \
181
+ --arg commit_hash "$COMMIT_HASH" \
182
+ 'if has("packages") then del(.packages) else . end |
183
+ .overview.latest_version = $version_tag |
184
+ if has("source_code") then
185
+ .source_code.version += [{
186
+ "tag": $version_tag,
187
+ "hash": $commit_hash,
188
+ "is_verified": false
189
+ }]
190
+ else
191
+ . + {"source_code": {"version": [{
192
+ "tag": $version_tag,
193
+ "hash": $commit_hash,
194
+ "is_verified": false
195
+ }]}}
196
+ end' \
197
+ metadata.json > tmp.json && mv tmp.json metadata.json
198
+
199
+ cp ../../../../README.md ./README.md
200
+
201
+ # Commit changes
202
+ git config user.name "GitHub Action"
203
+ git config user.email "[email protected] "
204
+ git add metadata.json README.md releases
205
+ git commit -m "Update ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}"
206
+
207
+ # Push changes
208
+ git push https://${{ secrets.PAT_TOKEN }}@github.com/hasura/ndc-hub.git HEAD:$NEW_BRANCH
209
+
210
+ # Create PR using GitHub CLI
211
+ cd ../..
212
+ gh pr create --repo hasura/ndc-hub \
213
+ --base main \
214
+ --head $NEW_BRANCH \
215
+ --title "Update ${{ env.CONNECTOR_NAME }} connector to v${{ steps.get-version.outputs.tagged_version }}" \
216
+ --body "This PR updates the ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}."
0 commit comments