Skip to content

fix: test commit

fix: test commit #15

Workflow file for this run

name: Determine Release Version
on:
pull_request:
branches:
- "master"
jobs:
version:
name: Versioning
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ env.GITHUB_SHA }}
- name: Output commit message
id: get-commit-messages
run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
- name: Get latest tag
uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
- name: Get commits comment
id: get_commits
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
COMMITS=$(curl -s -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER/commits")
COMBINED_MESSAGES=$(echo "$COMMITS" | jq -r '.[].commit.message' | paste -sd ' ')
echo "COMBINED_MESSAGES=$COMBINED_MESSAGES" >> $GITHUB_OUTPUT
- name: Check release type
id: release_type
run: |
if echo "${{ steps.get_commits.outputs.COMBINED_MESSAGES }}" | grep -q "feat"; then
echo "RELEASE_TYPE=major" >> $GITHUB_OUTPUT
elif echo "${{ steps.get_commits.outputs.COMBINED_MESSAGES }}" | grep -q "fix"; then
echo "RELEASE_TYPE=minor" >> $GITHUB_OUTPUT
else
echo "RELEASE_TYPE=patch" >> $GITHUB_OUTPUT
fi
- name: Determine next version
id: next_version
run: |
echo ${{ steps.get-latest-tag.outputs.tag }}
IFS='v' read -r -a VERSION <<< "${{ steps.get-latest-tag.outputs.tag }}"
IFS='.' read -r -a VERSION_PARTS <<< "${VERSION[1]}"
MAJOR=${VERSION_PARTS[0]}
MINOR=${VERSION_PARTS[1]}
PATCH=${VERSION_PARTS[2]}
if [ "${{ steps.release_type.outputs.RELEASE_TYPE }}" = "major" ]; then
echo $MAJOR
MINOR=$MINOR
PATCH=$PATCH
elif [ "${{ steps.release_type.outputs.RELEASE_TYPE }}" = "minor" ]; then
MINOR=$((MINOR + 1))
PATCH=$PATCH
else
PATCH=$((PATCH + 1))
fi
NEXT_TAG="$MAJOR.$MINOR.$PATCH"
echo "NEXT_TAG=$NEXT_TAG" >> $GITHUB_OUTPUT
- name: Print next version
id: print_next_version
run: echo ${{ steps.next_version.outputs.NEXT_TAG }}
- name: Script to comment on PR
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Current version => ${{ steps.next_version.outputs.NEXT_TAG }}'
})