Skip to content

Commit acbe4a3

Browse files
feat(release_create): Format VirusTotal results as asset table in release body (#38)
1 parent 05c79ca commit acbe4a3

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

actions/release_create/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
# release_create
22

33
A reusable action to create a GitHub release. This action is tailored to the
4-
@LizardByte organization, but can be used by anyone if they follow the same conventions.
4+
@LizardByte organization but can be used by anyone if they follow the same conventions.
55

6-
This is basically a wrapper around [ncipollo/release-action](https://github.com/ncipollo/release-action),
6+
This action started out as a wrapper around [ncipollo/release-action](https://github.com/ncipollo/release-action),
77
with some different defaults to make it easier to use within the @LizardByte organization.
8-
Additionally, all except the 2 (configurable) latest pre-releases and tags are deleted.
8+
Additionally, the following is handled automatically.
9+
10+
- all except the 2 (configurable) latest pre-releases and tags are deleted
11+
- assets are scanned using VirusTotal API and results are appended to the release notes
12+
- [node-badges](https://github.com/smashedr/node-badges) provides the VirusTotal badges
913

1014
## Basic Usage
1115

actions/release_create/action.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ runs:
8181
- name: Format VirusTotal Results
8282
env:
8383
INPUT_BODY: ${{ inputs.body }}
84+
INPUT_TAG: ${{ inputs.tag }}
8485
if: inputs.virustotal_api_key != ''
8586
id: format-vt
8687
shell: bash
@@ -91,23 +92,38 @@ runs:
9192
${INPUT_BODY}
9293
BODY_EOF
9394
94-
VT_HEADER="🛡️ **VirusTotal Results:**"
95+
ASSETS_HEADER="📦 **Assets:**"
9596
96-
# If we have VT results, append them
97+
# If we have existing results, append them
9798
if [ -n '${{ steps.vt.outputs.json }}' ]; then
98-
# Check if VirusTotal Results header already exists, if not add it
99-
if ! grep -qF "$VT_HEADER" ${rb_file}; then
99+
# Check if Assets header already exists, if not add it
100+
if ! grep -qF "$ASSETS_HEADER" ${rb_file}; then
100101
# Add separator if body exists and isn't empty
101102
if [ -s ${rb_file} ] && [ "$(cat ${rb_file} | tr -d '[:space:]')" != "" ]; then
102103
echo "" >> ${rb_file}
103104
fi
104105
105-
echo "---" >> ${rb_file}
106-
echo "$VT_HEADER" >> ${rb_file}
106+
{
107+
echo "---"
108+
echo "$ASSETS_HEADER"
109+
echo ""
110+
echo "| ⬇️ Download | #️⃣ Download Count | 🛡️ VirusTotal |"
111+
echo "|-------------|-------------------|---------------|"
112+
} >> ${rb_file}
107113
fi
108114
109-
# Append VirusTotal results
110-
printf '%s\n' '${{ steps.vt.outputs.json }}' | jq -r '.[] | "- [\(.name)](\(.link))"' >> ${rb_file}
115+
# Append VirusTotal results as table rows
116+
printf '%s\n' '${{ steps.vt.outputs.json }}' | \
117+
jq -r \
118+
--arg repo "${{ github.repository }}" \
119+
--arg tag "${INPUT_TAG}" \
120+
'.[] |
121+
"| [\(.name)](https://github.com/\($repo)/releases/download/\($tag)/\(.name)) | " +
122+
"![Downloads](https://img.shields.io/github/downloads/\($repo)/\($tag)/\(.name)" +
123+
"?style=flat-square&label=&displayAssetName=false) | " +
124+
"[![VirusTotal](https://badges.cssnr.com/vt/id/\(.id)" +
125+
"?style=flat-square&icon=virustotal&label=)](\(.link)) |"' \
126+
>> ${rb_file}
111127
fi
112128
113129
# Set output

0 commit comments

Comments
 (0)