Skip to content

Commit 334b9fd

Browse files
committed
multi-arch support for create-draft-release workflow
1 parent eece82e commit 334b9fd

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

.github/workflows/create-draft-release.yml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,43 @@ jobs:
118118
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
119119
buildpack_type: ${{ steps.get_buildpack_type.outputs.buildpack_type }}
120120

121+
- name: Create release assets
122+
id: create_release_assets
123+
run: |
124+
release_assets=$(jq -n --arg repo_name "${{ github.event.repository.name }}" --arg tag "${{ steps.tag.outputs.tag }}" '
125+
[
126+
{
127+
"path": "build/buildpack.tgz",
128+
"name": ($repo_name + "-" + $tag + ".tgz"),
129+
"content_type": "application/gzip"
130+
}
131+
]')
132+
133+
for filepath in build/*.cnb; do
134+
135+
filename=$(basename "$filepath")
136+
asset_name=""
137+
if [[ "$filename" == "buildpackage-linux-amd64.cnb" ]]; then
138+
asset_name="${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.cnb"
139+
elif [[ "$filename" == "buildpackage.cnb" ]]; then
140+
asset_name="${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.cnb"
141+
else
142+
asset_name="${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}-${filename}"
143+
fi
144+
145+
release_assets=$(echo "$release_assets" | jq --arg asset_name "${asset_name}" --arg filepath "$filepath" '
146+
. + [
147+
{
148+
"path": $filepath,
149+
"name": $asset_name,
150+
"content_type": "application/gzip"
151+
}
152+
]')
153+
done
154+
155+
release_assets=$(jq -c <<< "$release_assets" )
156+
printf "release_assets=%s\n" "${release_assets}" >> "$GITHUB_OUTPUT"
157+
121158
- name: Create Release
122159
uses: paketo-buildpacks/github-config/actions/release/create@main
123160
with:
@@ -128,19 +165,7 @@ jobs:
128165
name: v${{ steps.tag.outputs.tag }}
129166
body: ${{ steps.create-release-notes.outputs.release_body }}
130167
draft: true
131-
assets: |
132-
[
133-
{
134-
"path": "build/buildpack.tgz",
135-
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.tgz",
136-
"content_type": "application/gzip"
137-
},
138-
{
139-
"path": "build/buildpackage.cnb",
140-
"name": "${{ github.event.repository.name }}-${{ steps.tag.outputs.tag }}.cnb",
141-
"content_type": "application/gzip"
142-
}
143-
]
168+
assets: ${{ steps.create_release_assets.outputs.release_assets }}
144169

145170
failure:
146171
name: Alert on Failure

0 commit comments

Comments
 (0)