[v1.0.7] 크래시티릭스 배 포 #58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: auto-tagging | |
on: | |
pull_request: | |
branches: | |
- master | |
types: | |
- closed | |
jobs: | |
auto-tagging: | |
if: github.event.pull_request.merged == true && (contains(github.event.pull_request.labels.*.name, 'major') || contains(github.event.pull_request.labels.*.name, 'minor') || contains(github.event.pull_request.labels.*.name, 'patch')) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: get latest tag | |
run: | | |
latest_tag_version=$(git tag --sort=-v:refname | head -n 1) | |
echo "latest tag version is $latest_tag_version" | |
echo "LATEST_TAG_VERSION=${latest_tag_version}" >> $GITHUB_ENV | |
- name: set default tag version | |
run: | | |
current_tag=$(echo $LATEST_TAG_VERSION | sed 's/v//') | |
echo "major=$(echo $current_tag | cut -d. -f1)" >> $GITHUB_ENV | |
echo "minor=$(echo $current_tag | cut -d. -f2)" >> $GITHUB_ENV | |
echo "patch=$(echo $current_tag | cut -d. -f3)" >> $GITHUB_ENV | |
- name: major version up | |
if: contains(github.event.pull_request.labels.*.name, 'major') | |
run: | | |
new_major=$((major + 1)) | |
echo "major=${new_major}" >> $GITHUB_ENV | |
echo "new major version is $new_major" | |
- name: minor version up | |
if: contains(github.event.pull_request.labels.*.name, 'minor') | |
run: | | |
new_minor=$((minor + 1)) | |
echo "minor=$new_minor" >> $GITHUB_ENV | |
echo "new minor version is $new_minor" | |
- name: patch version up | |
if: contains(github.event.pull_request.labels.*.name, 'patch') | |
run: | | |
new_patch=$((patch + 1)) | |
echo "patch=${new_patch}" >> $GITHUB_ENV | |
echo "new patch version is $new_patch" | |
- name: print all version | |
run: | | |
echo "update version is v$major.$minor.$patch" | |
echo "new_tag=v$major.$minor.$patch" >> $GITHUB_ENV | |
- name: tagging | |
if: ${{ env.new_tag != env.LATEST_TAG_VERSION }} | |
run: | | |
git tag $new_tag | |
git push origin $new_tag | |
- name: print current tag | |
run: git tag |