Skip to content

Commit d2b9d7e

Browse files
authored
Merge pull request #351 from linuxserver/release-notes
use github generated release notes for LS changes
2 parents a124c42 + a9386a7 commit d2b9d7e

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

ansible/roles/repository/templates/Jenkinsfile.j2

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,16 @@ pipeline {
13151315
environment name: 'EXIT_STATUS', value: ''
13161316
}
13171317
steps {
1318+
echo "Auto-generating release notes"
1319+
sh '''if [ "$(git tag --points-at HEAD)" != "" ]; then
1320+
echo "Existing tag points to current commit, suggesting no new LS changes"
1321+
AUTO_RELEASE_NOTES="No changes"
1322+
else
1323+
AUTO_RELEASE_NOTES=$(curl -fsL -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github+json" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases/generate-notes \
1324+
-d '{"tag_name":"'${META_TAG}'",\
1325+
"target_commitish": "{{ ls_branch }}"}' \
1326+
| jq -r '.body' | sed 's|## What.s Changed||')
1327+
fi'''
13181328
echo "Pushing New tag for current commit ${META_TAG}"
13191329
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \
13201330
-d '{"tag":"'${META_TAG}'",\
@@ -1350,12 +1360,20 @@ pipeline {
13501360
{% elif external_type == "pip_version" %}
13511361
echo "Updating PIP version of ${EXT_PIP} to ${EXT_RELEASE_CLEAN}" > releasebody.json
13521362
{% elif external_type == "custom" %} echo "Custom External Release" > releasebody.json{% endif %}
1353-
echo '{"tag_name":"'${META_TAG}'",\
1354-
"target_commitish": "{{ ls_branch }}",\
1355-
"name": "'${META_TAG}'",\
1356-
"body": "**CI Report:**\\n\\n'${CI_URL:-N/A}'\\n\\n**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n\\n**Remote Changes:**\\n\\n' > start
1357-
printf '","draft": false,"prerelease": {% if release_type == "stable" %}false{% elif release_type == "prerelease" %}true{% endif %}}' >> releasebody.json
1358-
paste -d'\\0' start releasebody.json > releasebody.json.done
1363+
jq -n \
1364+
--arg tag_name "$META_TAG" \
1365+
--arg target_commitish "{{ ls_branch }}" \
1366+
--arg ci_url "${CI_URL:-N/A}" \
1367+
--arg ls_notes "$AUTO_RELEASE_NOTES" \
1368+
--arg remote_notes "$(cat releasebody.json)" \
1369+
'{
1370+
"tag_name": $tag_name,
1371+
"target_commitish": $target_commitish,
1372+
"name": $tag_name,
1373+
"body": ("**CI Report:**\\n\\n" + $ci_url + "\\n\\n**LinuxServer Changes:**\\n\\n" + $ls_notes + "\\n\\n**Remote Changes:**\\n\\n" + $remote_notes),
1374+
"draft": false,
1375+
"prerelease": {% if release_type == "stable" %}false{% elif release_type == "prerelease" %}true{% endif %}
1376+
}' > releasebody.json.done
13591377
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
13601378
}
13611379
}

0 commit comments

Comments
 (0)