Github Actions Release 자동화

Soobeen Yoon·2022년 11월 26일
0

학습을 진행하면서 작성했습니다..! 잘못된 정보가 있다면 말씀 부탁드립니다!!

도입 배경

버전 upgrade 시 latest release를 기준으로 version update를 해주는데, 이 기능이 너무 좋아보였다..!!

추후에 minor update를 할 때 스크립트를 가다듬으면 버전 관리를 더 잘 할 수 있을 것 같다.

release 이후 hotfix를 한다면 버전 관리를 어떻게 하면 좋을지 고민이다.

일반적으로는 commit message, github PR 만들때 PR tag 등으로 어떤 종류의 version update인지 명시하는 방식이 있다고 한다. (추후에 업데이트 해보겠습니다..!)

적용을 하기 위해서는 .github/workflows/ 하위에 yml 파일을 하나 만든다.

name: Release Github Application Version
on:
  pull_request:
    branches:
      - release

jobs:
  release-application:
    runs-on: ubuntu-latest
    steps:
      - name: Github Release 최신 tag 받아오기
        id: tag_version
        uses: mathieudutour/github-tag-action@v6.1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

      - name: GitHub project release 업데이트
        uses: ncipollo/release-action@v1
        with:
          tag: ${{ steps.tag_version.outputs.new_tag }}
          name: Release ${{ steps.tag_version.outputs.new_tag }}
          body: ${{ steps.tag_version.outputs.changelog }}

mathieudutour/github-tag-action

  • 현재까지 github에 등록되어 있는 latest release의 버전 정보를 가져온다.

  • 결과값으로 가져온 outputs의 new_tag는 설정에 맞게 다음 버전을 가져온다. (previous_tag는 현재 lastest version을 가져온다!)

  • changelog는 직전 버전과 비교하여 어떤 변화가 생겼는지 알려준다.

ncipollo/release-action

  • 실제적으로 release를 진행하는 actions이다.
  • 흥미로운 점은 위에서 가져온 changelog를 body에 넣어주면 commit header나 label을 바탕으로 구분해서 해당 release에 어떤 변화가 있었는지 알려준다!! (개꿀)

원래는 github release를 하나 하나 수작업으로 해야 했었는데, github actions를 통해서 귀찮은 작업을 줄일 수 있었다!

profile
클린코드, 자동화에 관심이 많은 FE 개발자입니다.

0개의 댓글