Skip to content

Commit

Permalink
modified: .github/workflows/package-release.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
yuleib committed May 11, 2023
1 parent f1342b0 commit 04b112b
Showing 1 changed file with 61 additions and 32 deletions.
93 changes: 61 additions & 32 deletions .github/workflows/package-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ on:
# type: boolean
# default: true
push:
branches: [main]
branches: [ main, master ]
tags:
- 'v*.*.*'

Expand Down Expand Up @@ -63,17 +63,46 @@ jobs:
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "Latest tag: $latest_tag"
- name: Extract version
id: extract_version
run: |
version=$(echo $latest_tag | jq -r 'sub("^[^0-9]*"; "")')
echo "Version: $version"
- name: Determine version bump
id: version_bump
run: |
tag=${{ steps.latest_tag.outputs.latest_tag }}
commit_range="${tag}..HEAD"
major_bump=$(git diff --name-only $commit_range | grep -E '^major-.*\.md$' | wc -l)
minor_bump=$(git diff --name-only $commit_range | grep -E '^minor-.*\.md$' | wc -l)
if [ $major_bump -gt 0 ]; then
echo "{name}={$bump_type} major" >> $GITHUB_OUTPUT
elif [ $minor_bump -gt 0 ]; then
echo "{name}={$bump_type} minor" >> $GITHUB_OUTPUT
else
echo "{name}={$bump_type} patch" >> $GITHUB_OUTPUT
fi
- name: Increase version
id: increase_version
run: |
next_version=$((version + 1))
echo "Next version: $next_version"
- name: Increment tag version
id: increment_tag
run: |
tag=${{ steps.latest_tag.outputs.latest_tag }}
bump_type=${{ steps.version_bump.outputs.bump_type }}
if [ $bump_type == "major" ]; then
tag=$(echo $tag | awk -F. '{$1++;$2=0;$3=0;print $0}')
elif [ $bump_type == "minor" ]; then
tag=$(echo $tag | awk -F. '{$2++;$3=0;print $0}')
else
tag=$(echo $tag | awk -F. '{$3++;print $0}')
fi
echo "{name}={$tag}" >> $GITHUB_OUTPUT
# - name: Extract version
# id: extract_version
# run: |
# version=$(echo $latest_tag | jq -r 'sub("^[^0-9]*"; "")')
# echo "Version: $version"

# - name: Increase version
# id: increase_version
# run: |
# next_version=$((version + 1))
# echo "Next version: $next_version"

# - name: Set tag name
# id: set_tag_name
Expand All @@ -83,34 +112,34 @@ jobs:
# echo "{name}={$tag_name}" >> $GITHUB_OUTPUT
# continue-on-error: true

- name: Set tag name
id: set_tag_name
run: |
# Get the latest tag name in the repository
last_tag=$(git describe --tags --abbrev=0)
# Extract the major, minor, and patch version numbers from the latest tag
major=$(echo "$last_tag" | cut -d'.' -f1 | sed 's/v//')
minor=$(echo "$last_tag" | cut -d'.' -f2)
patch=$(echo "$last_tag" | cut -d'.' -f3)
# Increment the patch version number
next_patch=$(($patch + 1))
# Set the new tag name with the incremented patch version number
tag_name="v$major.$minor.$next_patch"
# Set the tag_name output variable
echo "{name}={$tag_name}" >> $GITHUB_OUTPUT
continue-on-error: true
# - name: Set tag name
# id: set_tag_name
# run: |
# # Get the latest tag name in the repository
# last_tag=$(git describe --tags --abbrev=0)
# # Extract the major, minor, and patch version numbers from the latest tag
# major=$(echo "$last_tag" | cut -d'.' -f1 | sed 's/v//')
# minor=$(echo "$last_tag" | cut -d'.' -f2)
# patch=$(echo "$last_tag" | cut -d'.' -f3)
# # Increment the patch version number
# next_patch=$(($patch + 1))
# # Set the new tag name with the incremented patch version number
# tag_name="v$major.$minor.$next_patch"
# # Set the tag_name output variable
# echo "{name}={$tag_name}" >> $GITHUB_OUTPUT
# continue-on-error: true

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.set_tag_name.outputs.tag_name }}
release_name: Release ${{ steps.set_tag_name.outputs.tag_name }}
tag_name: ${{ steps.increment_tag.outputs.tag_name }}
name: Release ${{ steps.increment_tag.outputs.tag_name }}
body: |
Changes:
- First change
- Second change
Release ${{ steps.increment_tag.outputs.tag_name }}
-------------------------------
Add release notes here.
draft: false
prerelease: false

0 comments on commit 04b112b

Please sign in to comment.