How can I generate unique tag names in yml, for GitHub Action releases?

Viewed 136

My group and I are having issues with auto releases in Github Actions.

Our releases are scheduled twice a week. However, they fail because the tag_name in the yml files are not unique. Is there some way to generate unique names for the attribute tag_name? Such as commit sha, timestamps etc...

Below is the code:

on:
  push:
    branches:
      - main
    

name: Create Release

jobs:
  build:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body: |
            Release on push
          draft: false
          prerelease: false

Thanks in advance hope my question makes sense :)

So far I have tried several ways of using timestamps and commit sha... Non of it worked out.

0 Answers
Related