softprops / action-gh-release

πŸ“¦ :octocat: GitHub Action for creating GitHub Releases

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot set tag_name from env variable

RunningLeon opened this issue Β· comments

Hi, I was unable to set tag_name with an env variable, see the log below. The tag should be test but it created a new tag $TAG_NAME.

Run softprops/action-gh-release@v1
  with:
    tag_name: $TAG_NAME
    files: ./prebuild/mmdeploy-1.1.0-linux-x86_64.tar.gz
  
    token: ***
  env:
    PREBUILD_DIR: /data2/actions-runner/prebuild
    MMDEPLOY_VERSION: 1.1.0
    TAG_NAME: test
    OUTPUT_DIR: /data2/actions-runner/prebuild/1.1.0
πŸ‘©β€πŸ­ Creating new GitHub release for tag $TAG_NAME...
⬆️ Uploading mmdeploy-1.1.0-linux-x86_64.tar.gz...
πŸŽ‰ Release ready at https://github.com/RunningLeon/mmdeploy/releases/tag/%[24](https://github.com/RunningLeon/mmdeploy/actions/runs/5109632465/jobs/9184633360#step:7:24)TAG_NAME
##[debug]Node Action run completed with exit code 0

This is due to security reasons for GitHub Action workflow files: you are not allowed to execute shell scripts as inputs for Actions. But you can make the environment variable a GitHub output and call that output instead:

      - id: tag_name
        run: echo "version=$TAG_NAME" >> "$GITHUB_OUTPUT"
        env:
          TAG_NAME: test

      - uses: softprops/action-gh-release@v1
        with:
          tag_name: ${{ steps.tag_name.outputs.version }}

Thanks for your reply. I've used gh script to upload assets.

      - name: Upload assets
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh release upload ${TAG_NAME} ${OUTPUT_DIR}/*.zip ${OUTPUT_DIR}/*.tar.gz --clobber