Skip to content

Instantly share code, notes, and snippets.

@dio
Created November 18, 2022 01:11
Show Gist options
  • Save dio/c706dadabbebe3f4912e1b857662c4eb to your computer and use it in GitHub Desktop.
Save dio/c706dadabbebe3f4912e1b857662c4eb to your computer and use it in GitHub Desktop.

To infer "version" on a Github Actions workflow run:

    - name: "Set current version"
      id: current-version
      # When 'github.ref' starts with "refs/tags" it is a tag. Then we can infer the current
      # version from it. For example, given 'github.ref=refs/tags/1.6.0', the current version is 1.6.0.
      run: echo "version=${{ fromJSON('{"true":"${GITHUB_REF#refs/*/}"}')[startsWith(github.ref, 'refs/tags')] || 'next' }}" >> $GITHUB_OUTPUT

Set the trigger as:

  push:
    # Remember, if a push event contains tags, it ignores the "paths" filter.
    tags:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment