【问题标题】:Set current date and time as release APK name in GitHub workflows在 GitHub 工作流程中将当前日期和时间设置为发布 APK 名称
【发布时间】:2022-11-04 15:30:22
【问题描述】:

我有一个 GitHub 工作流程,用于发布存储库的夜间快照。这是工作流文件现在的样子:

# Define workflow name
name: main

# This workflow is triggered on pushes to the repository.
on:
  push:
    branches:
    - main
        
jobs:
  build:
    # This job will run on windows virtual machine
    runs-on: windows-latest

    steps:
    # Setup Java environment in order to build the Android app.
    - uses: actions/checkout@v1
    - uses: actions/setup-java@v1
      with:
        java-version: '12.x'

    # Setup the flutter environment.
    - uses: subosito/flutter-action@v1
      with:
        channel: 'stable' # 'dev', 'alpha', default to: 'stable'
        flutter-version: '3.3.7' # version of flutter
    
    # Get flutter dependencies.
    - run: flutter clean
    - run: flutter pub get
    
    # Build apk.
    - run: flutter build apk --release
    
    # Upload generated apk to the artifacts.
    - uses: actions/upload-artifact@v1
      with:
        name: app-release # want to set current date time over here
        path: build/app/outputs/flutter-apk/app-release.apk

我想要当前日期时间作为发布 apk 名称。但是,我找不到任何关于它的文档。我该怎么做?

【问题讨论】:

    标签: flutter github github-actions github-api cicd


    【解决方案1】:

    您可以在android/local.properties 中指定 versionName 和 versionCode

    flutter.versionName=YOUR-DATE-HERE
    flutter.versionCode=1
    

    更新

    您可以通过修改build.gradle文件来指定生成的apk文件的确切文件名

        buildTypes {
            applicationVariants.all{
                variant ->
                    variant.outputs.each{
                        // on below line we are setting a name to our apk
                        output->
                            def formattedDate = new Date().format('yyyy-MM-dd-HH-mm-ss')
                            output.outputFileName = formattedDate
                    }
            }
    }
    

    【讨论】:

    • 要将当前日期设置为发布 APK 名称,而不是版本名称。
    • 你的意思是apk文件名还是apk名称下的确切含义?
    • 工作流中的 apk 文件名。
    • 按照我更新的答案中的描述修改 build.gradle 文件
    猜你喜欢
    • 2020-07-11
    • 2020-08-20
    • 1970-01-01
    • 2012-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-23
    • 1970-01-01
    相关资源
    最近更新 更多