workflow: generate provider.json, upload to terralist
This commit is contained in:
parent
7cb14a872a
commit
c6ea12ed73
2 changed files with 57 additions and 4 deletions
12
.github/workflows/release.yaml
vendored
12
.github/workflows/release.yaml
vendored
|
|
@ -34,7 +34,11 @@ jobs:
|
|||
with:
|
||||
args: release --clean
|
||||
|
||||
- name: TEST output json (artifacts)
|
||||
run: echo "${{steps.goreleaser.outputs.artifacts}}"
|
||||
- name: TEST output json (metadata)
|
||||
run: echo "${{steps.goreleaser.outputs.metadata}}"
|
||||
- name: Generate and upload provider.json
|
||||
run: |
|
||||
echo '${{steps.goreleaser.outputs.artifacts}}' >artifacts.json
|
||||
echo '${{steps.goreleaser.outputs.metadata}}' >metadata.json
|
||||
./generate-provider-json.sh artifacts.json metadata.json
|
||||
env:
|
||||
TERRALIST_API: https://terralist.garm-provider-test.t09.de/v1/api
|
||||
TERRALIST_API_KEY: ${{ secrets.TERRALIST_API_KEY }}
|
||||
49
generate-provider-json.sh
Executable file
49
generate-provider-json.sh
Executable file
|
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
set -o errexit
|
||||
|
||||
# This script generates and uploads a terraform provider.json file and uploads it to Terralist
|
||||
|
||||
ARTIFACTS_FILE=$1
|
||||
METADATA_FILE=$2
|
||||
|
||||
TERRALIST_API=${TERRALIST_API:-https://terralist.garm-provider-test.t09.de/v1/api}
|
||||
TERRALIST_API_KEY=${TERRALIST_API_KEY:-invalid-key}
|
||||
|
||||
echo -e "\n__ARTIFACTS_FILE__"
|
||||
cat $ARTIFACTS_FILE | jq .
|
||||
echo -e "\n__METADATA_FILE__"
|
||||
cat $METADATA_FILE | jq .
|
||||
|
||||
VERSION=$(cat $METADATA_FILE | jq -r '.version')
|
||||
|
||||
jq --arg base "$FORGEJO_SERVER_URL/$FORGEJO_REPOSITORY/releases/download" --arg version "$VERSION" '
|
||||
{
|
||||
protocols: ["6"],
|
||||
|
||||
shasums: (
|
||||
{
|
||||
url: ($base + "/v" + $version + "/" + (.[]
|
||||
| select(.type=="Checksum").name)),
|
||||
signature_url: ($base + "/v" + $version + "/" + (.[]
|
||||
| select(.type=="Signature").name))
|
||||
}
|
||||
),
|
||||
|
||||
platforms: [
|
||||
.[]
|
||||
| select(.type=="Archive")
|
||||
| {
|
||||
os: .goos,
|
||||
arch: .goarch,
|
||||
download_url: ($base + "/v" + $version + "/" + .name),
|
||||
shasum: (.extra.Checksum | sub("^sha256:";""))
|
||||
}
|
||||
]
|
||||
}
|
||||
' $ARTIFACTS_FILE >./provider.json
|
||||
|
||||
cat provider.json | jq .
|
||||
|
||||
curl -X POST $TERRALIST_API/providers/edge-connect/${VERSION}/upload \
|
||||
-H "Authorization: Bearer x-api-key:$TERRALIST_API_KEY" \
|
||||
-d "$(cat ./provider.json)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue