Post
EN

github action add-and-commit, included update application version

github action은 여러 plugin들을 제공해주는데, PR내에 특정 label을 추가할 떄, 자동으로 application version을 update해주고 commit을 추가해주는 방법에 대해 알아보았다.

다행스럽게도 이런 기능을 이미 구현된 plugin이 존재했고, 이 plugin을 추가해서 version update하고 commit을 추가하는 github action을 작성해보았다.

앞서 task 정의는 아래 링크를 통해 확인할 수 있다.

https://blog.naver.com/kkforgg/223197409843

Gradle extract function and gradle version management

gradle project의 버전 관리에 대해 작성합니다. 구조 gradle version을 major, minor, patch로 구조로 나…

add&commit plugin

https://github.com/marketplace/actions/add-commit

Add & Commit - GitHub Marketplace

Automatically commit changes made in your workflow run directly to your repo

name: version-update run-name: check version update on: pull_request: types: - labeled env: GITHUB_WORKFLOW_URL: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} jobs: update-project-version: runs-on: self-hosted steps: - name: checkout uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.ref }} - name: setup jdk 17 uses: actions/setup-java@v2 with: java-version: '17' distribution: 'adopt' - name: Setup gradle uses: gradle/gradle-build-action@v2.4.2 - name: execute gradle major version update if: contains(github.event.pull_request.labels.*.name, 'major') run: ./gradlew --no-daemon --no-parallel major-version-update - name: execute gradle minor version update if: contains(github.event.pull_request.labels.*.name, 'minor') run: ./gradlew --no-daemon --no-parallel minor-version-update - name: execute gradle patch version update if: contains(github.event.pull_request.labels.*.name, 'patch') run: ./gradlew --no-daemon --no-parallel patch-version-update - name: add commit of major version update if: contains(github.event.pull_request.labels.*.name, 'major') uses: EndBug/add-and-commit@v9 with: committer_name: github-actions[bot] committer_email: ${{github.author_email}} message: "major version update" add: '.' push: true commit: --signoff force: true - name: add commit of minor version update if: contains(github.event.pull_request.labels.*.name, 'minor') uses: EndBug/add-and-commit@v9 with: committer_name: github-actions[bot] committer_email: ${{github.author_email}} message: "minor version update" add: '.' push: true commit: --signoff force: true - name: add commit of patch version update if: contains(github.event.pull_request.labels.*.name, 'patch') uses: EndBug/add-and-commit@v9 with: committer_name: github-actions[bot] committer_email: ${{github.author_email}} message: "patch version update" add: '.' push: true commit: --signoff force: true

This article is licensed under CC BY 4.0 by the author.