개발지식

ci/cd 에서 릴리즈

weaklion 2023. 7. 21. 17:13

원래 릴리즈시에 아래의 액션을 사용하려 했지만, 제가 생각하는 태그 번호와는 맞지 않아 바꿨습니다.

https://github.com/mathieudutour/github-tag-action

 

GitHub - mathieudutour/github-tag-action: A Github Action to automatically bump and tag master, on merge, with the latest SemVer

A Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform. - GitHub - mathieudutour/github-tag-action: A Github Action to autom...

github.com

auto tagging을 할 시에 위에 친절하게 나와있으니, 위 액션으로 하는 걸 권합니다.

 

저는 커밋에 있는 메세지를 가져와서 태그를 만들고, 릴리즈를 하고 싶었기에 아래 코드를 참조했습니다.

... 
 
 release:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: Echo commit message
        id: commit_title
        run: echo "title=$(echo '${{ github.event.head_commit.message }}' | egrep -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')" >>$GITHUB_OUTPUT
      - name: Create Release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ steps.commit_title.outputs.title }}
          release_name: Release ${{ steps.commit_title.outputs.title }}

커밋메세지에서 버전을 들고와 태그를 만듭니다.

커밋 메세지를 그대로 태그로 만들고 싶었는데, 릴리즈 과정에서 양식이 맞지 않다는 에러가 자꾸 떠서 숫자만 가져왔습니다.

ex ) hotfix-0.0.32 라고 커밋을 날린다면, 0.0.32 라는 태그와 릴리즈가 만들어지겠죠.

github.event.head_commit.message는 최신의 커밋 메세지를 가져와 보여줍니다.