continuous-integrationgithub-actionspublishgit-tag

GitHub Actions Not Triggered on Pushing Tags


I'm having a project for which I would like to do tag based releases and for this purpose, I have defined the following yml file:

name: publish open-electrons-templates

on:
  push:
    # Sequence of patterns matched against refs/tags
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]*'
  release:
    types: [ created ]

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  publish:
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/v')
    steps:
      - name: checkout
        uses: actions/checkout@v3

      - name: capture changelog
        id: changelog
        uses: metcalfc/changelog-generator@v4.0.1
        with:
          myToken: ${{ secrets.GITHUB_TOKEN }}

      - name: sbt ci-publish-github
        run: sbt compile publish

      - name: ci-release-github
        id: create-release
        uses: actions/create-release@latest
        with:
          allowUpdates: true
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body: |
            ## What's Changed
            ${{ steps.changelog.outputs.changelog }}
          draft: false
          prerelease: false

I then do the annotated tagging like;

git tag -a v2.2.2 -m "Your comments" // Create annotated tag

git push origin --tags               // Push annotated tag

I was expecting that the GitHub Actions would be triggered, but seems not and I'm also not sure how to debug it to find out why.

EDIT: After changing the Regex,

v[0-9]+.[0-9]+.[0-9](?:[+-[a-zA-Z]*])?

the pipeline seem to trigger but now fails:

push event contained invalid tags patterns: the following globs were invalid: v[0-9]+.[0-9]+.[0-9](?:[+-[a-zA-Z]*])?

But what is wrong with my new Regex? It seems to be valid and seems to match the following which is exactly what I want:

v0.0.1
v0.0.1-SNAPSHOT
v0.0.1-BETA
v0.0.1-RC

Solution

  • Took a workaround to get this fixed:

    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+-[a-zA-Z]*'
      - 'v[0-9]+.[0-9]+.[0-9]'