Unable to trigger GitHub release due to missing tag

The following workflow yml is to be ran each time a push to master branch is triggered:

name: Build APK Release
on:
  push:
    branches:
      - master
jobs:
  build:
    name: Build APK
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: Setup Java
        uses: actions/setup-java@v1
        with:
          java-version: "12.x"
      - name: Setup Flutter
        uses: subosito/flutter-action@v1
        with:
          flutter-version: "1.17.5"

      - name: Pub Get Packages
        run: flutter pub get

      - name: Build APK
        run: flutter build apk --split-per-abi --release

      - name: Build APPBUNDLE
        run: flutter build appbundle --release

      - name: Create Github Release
        uses: ncipollo/release-action@v1
        with:
          artifacts: "build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/*.aab"
          token: ${{ secrets.TOKEN }}

However, this Create GitHub Release section requires a tag name in the with section. I am confused by this requirement, and most tutorials try to run this job on an update to tags in general instead of an update to a specific branch only. I can manually set a name for the tag, but that fails the next time the action runs, and updating this workflow each time I push to master with a new name seems the opposite of the concept here.

I create a new tag in git and push to origin git push origin --tags and then push my commit to master. The action runs, but fails with the error “Error undefined: No tag found in ref or input!” at the Create GitHub Release portion of the workflow.

How would I update this workflow to meet my main goal - build an APK and push a GitHub Release only when master branch is updated - regardless of a tag?

@zachisit,

On GitHub, each release is based on a Git tag, which marks a specific point in your repository’s history. When you create a release, you must specify an existing tag or create a new tag for the release. To view more details, you can see “About releases”.

In your case, when you use the “ncipollo/release-action” action to create a new release, you need to specify a tag name for the input “tag”. Normally, if the specified tag is existing, the release can be created. And if the specified tag is not existing, typically GitHub will automatically create a tag with the specified tag name for the release based on the latest commit on the default or master branch.

In addition, GitHub also provides an official action “actions/create-release” to create new release, and another official action “actions/upload-release-asset” to upload release assets.

You can use wildcards in the tag definition:

on:
  push:
    tags: 
      - '*'

Anytime a tag is pushed.

Edit: Technically I guess if you want it to be literally any tag then it would be ** to match “any” tag.

Tags are not pushed to branches, that definition will trigger the build on any push to master and for any pushed tag where the tag name doesn’t contain a slash.

Right, edited to be more correct.

1 Like