【问题标题】:android with github actions带有 github 操作的 android
【发布时间】:2021-05-01 03:22:54
【问题描述】:

我正在尝试使用操作在 android 中自动化我的版本控制,这是我第一次使用这项技术 所以我有3个命令: ./gradlew bumpPatch ./gradlew bumpMinor ./gradlew bumpMajor 例如,我如何确定从 PR 到 master 执行哪一个:

branch fix/foo --> 执行 ./gradlew bumpPatch

branch feat/foo --> 执行 ./gradlew bumpMinor

branch perf/foo --> 执行 ./gradlew bumpMajor

以及我该怎么做。

我正在关注语义发布,所以也许最好从提交消息中执行命令,但仍然不知道如何执行这两个操作,因此不胜感激。

name: Android CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Grant execute permission for gradlew
      run: chmod +x gradlew
    - name: Build with Gradle
      run: ./gradlew build

【问题讨论】:

    标签: android github github-actions


    【解决方案1】:

    使用以下工作流程。它仅在针对 main 的拉取请求时触发。它使用条件步骤 (if) 和使用函数 startsWith 的表达式。

    name: Android CI
    
    on:
      pull_request:
        branches: [ main ]
    
    jobs:
      build:
    
        runs-on: ubuntu-latest
    
        steps:
        - uses: actions/checkout@v2
        - name: set up JDK 1.8
          uses: actions/setup-java@v1
          with:
            java-version: 1.8
        - name: Grant execute permission for gradlew
          run: chmod +x gradlew
        - run: ./gradlew bumpPatch
          if: startsWith(github.head_ref, 'fix/')
        - run: ./gradlew bumpMinor
          if: startsWith(github.head_ref, 'feat/')
        - run: ./gradlew bumpMajor
          if: startsWith(github.head_ref, 'perf/')
        - name: Build with Gradle
          run: ./gradlew build
    

    【讨论】:

      猜你喜欢
      • 2020-12-21
      • 2022-01-01
      • 2022-07-12
      • 1970-01-01
      • 2021-04-27
      • 2013-02-23
      • 1970-01-01
      • 2021-06-30
      • 2021-10-18
      相关资源
      最近更新 更多