You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过GitHub Action为Firebase App Distribution设置版本号?

解决方案

Firebase App Distribution 的 appdistribution:distribute 命令默认读取安装包内的版本信息,但如果要自定义控制台显示的版本号,可使用 --version-name 参数手动指定。同时修正版本号提取的脚本错误,以下是调整后的完整 GitHub Action 脚本:

# Extract Version from Git Tag
- name: Extract Version from Tag
  id: extract_version
  run: echo "::set-output name=version::$(echo ${{ github.ref }} | sed -n 's/^refs\/tags\/v//p')"

# Extract Release Notes from Tag Message
- name: Extract Release Notes from Tag
  id: get_tag_message
  run: |
    tag_message=$(git log -1 --pretty=%B)
    echo "::set-output name=tag-message::$tag_message"

# Upload APK to Firebase App Distribution
- name: Upload APK to Firebase App Distribution
  run: |
    firebase appdistribution:distribute build/app/outputs/flutter-apk/app-release.apk \
    --app "${{ secrets.APPID }}" \
    --groups "testers" \
    --debug \
    --version-name "${{ steps.extract_version.outputs.version }}" \
    --release-notes "Version: ${{ steps.extract_version.outputs.version }} | Release Notes: ${{ steps.get_tag_message.outputs.tag-message }}"

关键调整说明

  • 修正版本号提取逻辑:原 sed 命令写法有误,改为 s/^refs\/tags\/v//p,可正确从 refs/tags/v1.0.0 这类标签中提取出纯版本号(如 1.0.0)。
  • 添加自定义版本号参数:新增 --version-name "${{ steps.extract_version.outputs.version }}",该参数会将 Git Tag 提取的版本号设置为 Firebase App Distribution 控制台显示的版本名称,对应你截图中的目标位置。
  • 可选:自定义版本代码:如果需要覆盖安装包的版本代码,可额外添加 --version-code <你的版本代码> 参数,版本代码可从 Tag 或其他渠道提取传入。

内容的提问来源于stack exchange,提问作者mnhmilu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 22:08:09