Flutter codebase to APK build in GitHub Actions returns 'undefined: No tag found in ref or input!'

Viewed 654

I'm using the following Actions YAML to try to build an Android APK from a Flutter app:

name: CI
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
jobs:
  build-and-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      # we need java to build android apks
      - uses: actions/setup-java@v1
        with:
          java-version: '12.x'
      # this flutter action does the heavy lifting for us
      - uses: subosito/flutter-action@v1
        with:
          channel: 'stable'
      # get packages as you used to in your computer
      - run: flutter pub get
      # Now build apk
      - run: flutter build apk --split-per-abi
      # now relase the just created build
      - name: Create a Release APK
        uses: ncipollo/release-action@v1
        with:
          artifacts: "build/app/outputs/apk/release/*.apk"
          token: ${{ secrets.TOKEN }}

When this is ran, it fails, returning:

0s
Run ncipollo/release-action@v1
  with:
    artifacts: build/app/outputs/apk/release/*.apk
    token: ***
    omitBody: false
    omitBodyDuringUpdate: false
    omitName: false
    omitNameDuringUpdate: false
    replacesArtifacts: true
  env:
    JAVA_HOME_12.0.2_x64: /opt/hostedtoolcache/jdk/12.0.2/x64
    JAVA_HOME: /opt/hostedtoolcache/jdk/12.0.2/x64
    JAVA_HOME_12_0_2_X64: /opt/hostedtoolcache/jdk/12.0.2/x64
    FLUTTER_HOME: /opt/hostedtoolcache/flutter/1.22.0-stable/x64
Error: Error undefined: No tag found in ref or input!

At the 'Create and Release APK' stage of the action. I'm trying to figure this out. What is my YAML missing, or is this a one-off scenario?

1 Answers

As per the notes you either need to specify an existing tag or specify a branch or commit for the commit input of the action, based on which a tag will be created:

  • You must provide a tag either via the action input or the git ref (i.e push / create a tag). If you do not the action will fail.
  • If the tag of the release you are creating does not exist yet, you should set both the tag and commit action inputs. commit can point to a commit hash or a branch name (ex - main).

from https://github.com/ncipollo/release-action#notes

Using the following will give you a new version tag with every run, where the last place of the version is incremented for every run.

[...]
# now relase the just created build
      - name: Create a Release APK
        uses: ncipollo/release-action@v1
        with:
          artifacts: "build/app/outputs/apk/release/*.apk"
          token: ${{ secrets.TOKEN }}
          commit: master
          tag: v1.0.${{ github.run_number }}
Related