-
Notifications
You must be signed in to change notification settings - Fork 308
Document an example of tagging with a version #39
Comments
@nathany, AFAIK there is no other solution to dynamically set the |
@nathany Is there a better way? - name: Get version
run: echo ::set-env name=version::$(cat VERSION) Then: - name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.version }}
release_name: v${{ env.version }}
draft: false
prerelease: false |
PS: In my case, the version is stored inside my package.json and since I use actions/setup-node@v1, I extract the version like this: run: echo ::set-env name=version::$(node -pe "require('./package.json').version") |
Hi @PeterHewat , I also encountered a problem and want to create the version name and release notes from a txt file. Did you find a solution for this yet? |
@RP-101 I used a similar solution to what @PeterHewat shared, but had to come up with my own way to add release notes from our text file. Here's both steps: - name: Get Version
id: vars
run: echo ::set-output name=version::$(node -e "console.log(require('./version.json').version);")
- name: Get Release Notes
id: notes
run: |
notes=$(cat .release_notes)
notes="${notes//'%'/'%25'}"
notes="${notes//$'\n'/'%0A'}"
notes="${notes//$'\r'/'%0D'}"
echo "::set-output name=release_notes::$notes"
I was able to reference these vars in the step to create the release like this:
|
How can I set |
It took a few attempts to find a solution to get a version # to tag the releases with. In my case I have a VERSION file containing the version number, such as
0.1.0
. This solution should be applicable even if the desired version is stored elsewhere so long as it can be accessed from a bash shell.The first step gets the version via a run command and sets the output. See the documentation for set-output.
Then the id can be used to access the output for the tag and release name:
Is there a better way? I had no success using
cat
outside of arun
step, but I didn't try every possibility.In #31 I noticed that @fleskesvor wrote a more elaborate solution, which is another reason to document what GitHub Actions provides out-of-the-box.
The text was updated successfully, but these errors were encountered: