@@ -102,9 +102,12 @@ jobs:
102102 tag_name : ${{ steps.version.outputs.tag }}
103103 name : Release ${{ steps.version.outputs.tag }}
104104 generate_release_notes : true
105-
105+
106106 - name : Publish Artifact Hub metadata branch
107107 run : |
108+ sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
109+ sudo chmod +x /usr/local/bin/yq
110+
108111 VERSION="${{ steps.version.outputs.version }}"
109112 TAG="${{ steps.version.outputs.tag }}"
110113 TARBALL="${{ steps.package.outputs.tarball }}"
@@ -113,35 +116,42 @@ jobs:
113116
114117 WORKDIR="$(mktemp -d)"
115118
116- git clone --depth 1 --branch artifacthub \
117- "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" \
118- "$WORKDIR" || {
119- git clone --depth 1 \
120- "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" \
121- "$WORKDIR"
122- cd "$WORKDIR"
123- git checkout --orphan artifacthub
124- git rm -rf .
125- }
119+ if git ls-remote --exit-code --heads origin artifacthub >/dev/null 2>&1; then
120+ git clone --depth 1 --branch artifacthub \
121+ "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" \
122+ "$WORKDIR"
123+ else
124+ git clone --depth 1 \
125+ "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" \
126+ "$WORKDIR"
127+ cd "$WORKDIR"
128+ git checkout --orphan artifacthub
129+ git rm -rf .
130+ cd -
131+ fi
132+
133+ cp artifacthub-pkg.yml "$WORKDIR/artifacthub-pkg.yml"
126134
127135 cd "$WORKDIR"
128136
129- cat > artifacthub-pkg.yml <<EOF
130- version: "$VERSION"
131- name: "${{ github.event.repository.name }}"
132- displayName: "${{ github.event.repository.name }}"
133- createdAt: "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
134- annotations:
135- headlamp/plugin/archive-url: "$ARCHIVE_URL "
136- headlamp/plugin/ archive-checksum: "sha256:$CHECKSUM "
137- EOF
137+ yq -i '.version = strenv(VERSION)' artifacthub-pkg.yml
138+ yq -i '.createdAt = strenv(CREATED_AT)' artifacthub-pkg.yml
139+ yq -i '.annotations."headlamp/plugin/archive-url" = strenv(ARCHIVE_URL)' artifacthub-pkg.yml
140+ yq -i '.annotations."headlamp/plugin/archive-checksum" = "sha256:" + strenv(CHECKSUM)' artifacthub-pkg.yml
141+
142+ echo "✅ artifacthub-pkg.yml updated:"
143+ echo " version: $VERSION "
144+ echo " archive-url: $ARCHIVE_URL "
145+ echo " checksum: sha256:$CHECKSUM"
138146
139147 git config user.name "github-actions[bot]"
140148 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
141149
142150 git add artifacthub-pkg.yml
143151 git commit -m "chore(release): publish Artifact Hub metadata for $TAG" || echo "No changes to commit"
144152 git push origin artifacthub
153+ env :
154+ CREATED_AT : ${{ steps.version.outputs.created_at }}
145155
146156 - name : Login to GitHub Container Registry
147157 uses : docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
0 commit comments