create-release
create-release copied to clipboard
"Body" of release not created correctly.
Testing, I copied and pasted the example on the README
but did not get expected results. The release was created with the correct tags and commits but the body of the release was empty. When I changed to use master
this worked.
actions/create-release@v1
Body of release was empty.
actions/create-release@master
Body of release correctly displayed.
I assume everyone else is using @v1
so what am I doing wrong? Or is there a bug fix in the master branch?
Thanks!!
I got the same problem. This is because the body
passing is a new functionality that is not available in V1. See https://github.com/actions/create-release/pull/11
Duplicate of #30 and #35.
/cc @ethomson
Could you please tag a version 1.1.0
because depending on master to use the body feature is not the best idea ;)
Thanks for the nice action :)
I have tried many times 😂
With anyone using the latest and driving themselves mad because only the first line of the body
shows up, here is a solution.
The trick being, you have to escape all new line characters and carriage returns before passing them into set-output.
- name: Prep Release
id: prep
run: |
cd cli
# Parse version
VERSION=$(./scripts/get_version.sh)
echo "Setting release version to $VERSION"
echo "::set-env name=RELEASE_VERSION::$VERSION"
# Parse changelog
CHANGELOG=$(./scripts/parse_changelog.sh)
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
echo "Got changelog: $CHANGELOG"
echo "::set-output name=changelog::$CHANGELOG"
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: Release ${{ env.RELEASE_VERSION }}
body: ${{ steps.prep.outputs.changelog }}
draft: false
prerelease: true
It seems ::set-output
(and ::set-env
for that matter) have been deprecated due to a vulnerability. I tried using the multiline string example that the blog post refers to, but I didn't get it to work...
Specifically, if I don't do the character replacement as pointed out by @mancej then the entire changelog appears as one long line. If I do the character replacement as pointed out by @mancej then the entire changelog appears as one long line but with the %25
, %0A
, and %0D
inserted...
Perhaps I'm just misunderstanding echo $CHANGELOG >> $GITHUB_ENV
? Does anyone have any insights into what is going wrong here? I'm probably not the only one with this issue and it would be nice to have an up-to-date example (i.e. one that doesn't use ::set-output
) anyway...
- name: Prep Release
id: prep
run: |
cd cli
# Parse version
VERSION=$(./scripts/get_version.sh)
echo "Setting release version to $VERSION"
echo "::set-env name=RELEASE_VERSION::$VERSION"
# Parse changelog
CHANGELOG=$(./scripts/parse_changelog.sh)
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
- echo "Got changelog: $CHANGELOG"
- echo "::set-output name=changelog::$CHANGELOG"
+ echo 'changelog<<EOF' >> $GITHUB_ENV
+ echo $CHANGELOG >> $GITHUB_ENV
+ echo 'EOF' >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: Release ${{ env.RELEASE_VERSION }}
- body: ${{ steps.prep.outputs.changelog }}
+ body: ${{ env.GITHUB_ENV.changelog }}
draft: false
prerelease: true
As an aside, it seems the v1 tag has been updated to point to v1.1.4 (see https://github.com/actions/create-release/tags), which would make this issue resolved?
> - echo "Got changelog: $CHANGELOG"
> - echo "::set-output name=changelog::$CHANGELOG"
> + echo 'changelog<<EOF' >> $GITHUB_ENV
> + echo $CHANGELOG >> $GITHUB_ENV
> + echo 'EOF' >> $GITHUB_ENV
>
> body: ${{ steps.prep.outputs.changelog }}
Hey Eric, could it possibly be that you are still referencing steps.prep.outputs.changelog
in your Create Release
step instead of now env.GITHUB_ENV
?
It could be just a mistake in your example, but that looks suspicious to me .
Oops :sweat_smile: Thanks for pointing this out, it is indeed a mistake in the example (with the ::set-output
line removed the body would be empty or given an error). I fixed the example in my previous comment and, for clarity, here is a "raw" example (rather than a diff). Hopefully now it is a correct example :crossed_fingers:
- name: Prep Release
id: prep
run: |
cd cli
# Parse version
VERSION=$(./scripts/get_version.sh)
echo "Setting release version to $VERSION"
echo "::set-env name=RELEASE_VERSION::$VERSION"
# Parse changelog
CHANGELOG=$(./scripts/parse_changelog.sh)
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
echo 'changelog<<EOF' >> $GITHUB_ENV
echo $CHANGELOG >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_VERSION }}
release_name: Release ${{ env.RELEASE_VERSION }}
body: ${{ env.GITHUB_ENV.changelog }}
draft: false
prerelease: true