-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
762410d
commit cfe5737
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Determine Release Version | ||
on: | ||
pull_request: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
version: | ||
name: Versioning | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Get PR commits | ||
id: get_commits | ||
run: | | ||
LATEST_COMMIT=$(curl -s -H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits" \ | ||
| jq -r '.[-1].commit.message') | ||
echo "LATEST_COMMIT=$LATEST_COMMIT" >> $GITHUB_ENV | ||
- name: Set release type based on latest commit message | ||
id: set_release_type | ||
run: | | ||
if echo "${{ env.LATEST_COMMIT }}" | grep -q "feat"; then | ||
echo "RELEASE_TYPE=major" >> $GITHUB_ENV | ||
elif echo "${{ env.LATEST_COMMIT }}" | grep -q "fix"; then | ||
echo "RELEASE_TYPE=minor" >> $GITHUB_ENV | ||
else | ||
echo "RELEASE_TYPE=patch" >> $GITHUB_ENV | ||
- name: Display release type | ||
run: | | ||
echo "The determined release type is ${{ env.RELEASE_TYPE }}" | ||
# 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: 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: '👋 Thanks for reporting! ${{ steps.get-latest-tag.outputs.tag }} ${{ github.event.workflow_run.head_commit.message }}' | ||
# }) |