Search code examples
githubgithub-actionscicd

Why is the release-action on Github not working?


I'm using the github actions release-action@v1 in my workflow, and it's not generating artifacts after signing the app and building the apk and app bundle.

I created a tag before pushing to the repository, but the action is still not working.

I think it's because am not passing a commit to the workflow.

What do I need to do there?

Error:

  with:
    artifacts: build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/app-release.aab
    token: ***
    generateReleaseNotes: false
    omitBody: false
    omitBodyDuringUpdate: false
    omitName: false
    omitNameDuringUpdate: false
    omitPrereleaseDuringUpdate: false
    removeArtifacts: false
    replacesArtifacts: true
  env:
    KEY_JKS: ***
    KEY_PATH: key.jks
    KEY_PASSWORD: ***
    ALIAS_PASSWORD: ***
    JAVA_HOME: /opt/hostedtoolcache/Java_Adopt_jdk/12.0.2-10.1/x64
    FLUTTER_ROOT: /opt/hostedtoolcache/flutter/2.10.2-stable/x64
    PUB_CACHE: /opt/hostedtoolcache/flutter/2.10.2-stable/x64/.pub-cache
Error: Error undefined: No tag found in ref or input!

Workflow:

name: Flutter CICD # action name

on:
  push:
    branches:
      - master
    tags:
      - "v*"
  # push:git
  #   branches: [ android-stable ]

jobs:
  build: # job's na me
    runs-on: ubuntu-latest # container os
    env: # ADD environment variables 
      KEY_JKS: ${{ secrets.KEY_JKS }}
      KEY_PATH: "key.jks"
      KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
      ALIAS_PASSWORD: ${{ secrets.ALIAS_PASSWORD }}
    steps:
      - uses: actions/checkout@v2 # cd to current dir
      - uses: actions/setup-java@v2
        with:
          distribution: 'adopt' # See 'Supported distributions' for available options
          java-version: '12.x'
      - name: Create key file
        run: echo $KEY_JKS | base64 -di > key.jks
      - uses: subosito/flutter-action@v1
        with:
          flutter-version: '2.10.2' # change accordingly
      - run: flutter pub get
      # Statically analyze the Dart code for any errors.
      # - run: flutter analyze
      # Check for any formatting issues in the code.
      # - run: flutter format --set-exit-if-changed .
      # - run: flutter test
      - run: flutter build apk --release --split-per-abi
      - run: flutter build appbundle
      - name: Create github artifact release # disable this to save storage
        uses: ncipollo/release-action@v1
        with:
          artifacts: "build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/app-release.aab"
          token: ${{ secrets.GITHUB_TOKEN }} # this is automatically provided by github
          # commit: ${{!github!}}
      - name: Upload app bundle artifact
        uses: actions/upload-artifact@v2
        with:
          name: appbundle
          path: build/app/outputs/bundle/release/app-release.aab

Solution

  • The action documentation states that:

    You must provide a tag either via the action input or the git ref (i.e push / create a tag). If you do not provide a tag the action will fail.

    Moreover, the tag input states:

    tag: An optional tag for the release. If this is omitted the git ref will be used (if it is a tag).

    Your issue is probably related to the push trigger you set in your workflow file, as it will not generate any git ref tag. And as you're not using the action tag input, the action can't identify the tag to use to generate the release.

    You have 2 options here:

    • Remove the on push trigger. For the workflow, and consequently the action, only run if a tag is present.
    • Add the tag input to the action with the artifacts and the token inputs you're already using.