为什么 Github 上的释放操作不起作用?

Why is the release-action on Github not working?

我在我的工作流程中使用了 github 操作 release-action@v1,它在签署应用程序并构建 apk 和应用程序包后没有生成工件。

我在推送到存储库之前创建了一个标签,但该操作仍然无效。

我认为这是因为我没有将 commit 传递给工作流程。

我需要在那里做什么?

错误:

  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!

工作流程:

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

action documentation 指出:

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.

此外,标签输入状态:

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

您的问题可能与您在工作流文件中设置的 push 触发器有关,因为它不会生成任何 git ref 标记。由于您没有使用动作标签输入,动作无法识别用于生成发布的标签。

这里有 2 个选项:

  • 删除按下触发器。对于工作流程和相应的操作,只有 运行 如果存在标签。
  • 使用您已经在使用的 artifactstoken 输入将标签输入添加到操作中。