Fix drafter to use correct version
This commit is contained in:
@@ -51,9 +51,7 @@ jobs:
|
||||
if: github.ref == 'refs/heads/master'
|
||||
id: determine_bump
|
||||
run: |
|
||||
# Step 1: Check if the PR has a label (priority over commit message)
|
||||
pr_number=$(gh pr list --state merged --base master --limit 1 --json number --jq '.[0].number')
|
||||
echo "PR Number: $pr_number"
|
||||
labels=$(gh pr view "$pr_number" --json labels --jq '.labels[].name' || echo "")
|
||||
if echo "$labels" | grep -q 'major'; then
|
||||
bump="major"
|
||||
@@ -62,40 +60,40 @@ jobs:
|
||||
elif echo "$labels" | grep -q 'patch'; then
|
||||
bump="patch"
|
||||
fi
|
||||
# Step 2: If no label, fallback to commit message keywords
|
||||
|
||||
if [ -z "$bump" ]; then
|
||||
last_commit_msg=$(git log -1 --pretty=%B)
|
||||
echo "Last commit message: $last_commit_msg"
|
||||
|
||||
if echo "$last_commit_msg" | grep -iq '#major'; then
|
||||
bump="major"
|
||||
gh pr edit "$pr_number" --add-label "major" || echo "Could not add major label"
|
||||
elif echo "$last_commit_msg" | grep -iq '#minor'; then
|
||||
bump="minor"
|
||||
gh pr edit "$pr_number" --add-label "minor" || echo "Could not add minor label"
|
||||
elif echo "$last_commit_msg" | grep -iq '#patch'; then
|
||||
bump="patch"
|
||||
gh pr edit "$pr_number" --add-label "patch" || echo "Could not add patch label"
|
||||
else
|
||||
bump="patch" # Default to patch if no keyword or label
|
||||
bump="patch"
|
||||
gh pr edit "$pr_number" --add-label "patch" || echo "Could not add patch label"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "bump=$bump" >> $GITHUB_ENV
|
||||
echo "Version bump type: $bump"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Auto-Increment Version (Only for Master)
|
||||
- name: Update Release Draft (Only for Master)
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: release-drafter/release-drafter@v6
|
||||
id: release_drafter
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Get Release Version
|
||||
if: github.ref == 'refs/heads/master'
|
||||
id: bump_version
|
||||
run: |
|
||||
old_version="${{ env.latest_tag }}"
|
||||
IFS='.' read -r -a parts <<< "${old_version//[!0-9.]/}"
|
||||
if [ "${{ env.bump }}" = "major" ]; then
|
||||
new_version="$((parts[0] + 1)).0.0"
|
||||
elif [ "${{ env.bump }}" = "minor" ]; then
|
||||
new_version="${parts[0]}.$((parts[1] + 1)).0"
|
||||
else
|
||||
new_version="${parts[0]}.${parts[1]}.$((parts[2] + 1))"
|
||||
fi
|
||||
new_tag="v${new_version}"
|
||||
new_tag="${{ steps.release_drafter.outputs.tag_name }}"
|
||||
echo "new_tag=$new_tag" >> $GITHUB_ENV
|
||||
echo "New version: $new_tag"
|
||||
|
||||
@@ -115,14 +113,6 @@ jobs:
|
||||
echo "image_tag=$image_tag" >> $GITHUB_ENV
|
||||
echo "Image tag: $image_tag"
|
||||
|
||||
- name: Create Git Tag (Only for Master)
|
||||
if: github.ref == 'refs/heads/master'
|
||||
run: |
|
||||
git config --global user.name "github-actions"
|
||||
git config --global user.email "github-actions@github.com"
|
||||
git tag ${{ env.new_tag }}
|
||||
git push origin ${{ env.new_tag }}
|
||||
|
||||
- name: Build and Push Docker Image (Docker Hub & GHCR)
|
||||
run: |
|
||||
docker buildx create --use
|
||||
@@ -143,14 +133,14 @@ jobs:
|
||||
--tag ghcr.io/booklore-app/booklore:latest \
|
||||
--push .
|
||||
|
||||
- name: Update Release Draft (Only for Master)
|
||||
- name: Create Git Tag (Only for Master)
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: release-drafter/release-drafter@v6
|
||||
with:
|
||||
tag: ${{ env.new_tag }}
|
||||
name: "Release ${{ env.new_tag }}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
git config --global user.name "github-actions"
|
||||
git config --global user.email "github-actions@github.com"
|
||||
git tag ${{ env.new_tag }}
|
||||
git push origin ${{ env.new_tag }}
|
||||
|
||||
|
||||
- name: Publish Draft Release (Only for Master)
|
||||
if: github.ref == 'refs/heads/master'
|
||||
@@ -174,20 +164,17 @@ jobs:
|
||||
fi
|
||||
echo "Preparing Discord notification for release $NEW_TAG"
|
||||
|
||||
# fetch release info
|
||||
release_json=$(gh release view "$NEW_TAG" --json name,body,url)
|
||||
release_name=$(jq -r '.name' <<< "$release_json")
|
||||
release_body=$(jq -r '.body' <<< "$release_json")
|
||||
release_url=$(jq -r '.url' <<< "$release_json")
|
||||
|
||||
# trim body if too long
|
||||
clean_body=$(echo "$release_body" | tr -d '\r')
|
||||
max_length=1800
|
||||
if [ ${#clean_body} -gt $max_length ]; then
|
||||
clean_body="${clean_body:0:$((max_length-12))}… [truncated]"
|
||||
fi
|
||||
|
||||
# build JSON payload
|
||||
payload=$(jq -n \
|
||||
--arg title "New Release: $release_name" \
|
||||
--arg url "$release_url" \
|
||||
@@ -206,4 +193,4 @@ jobs:
|
||||
echo "$payload"
|
||||
echo "======================="
|
||||
|
||||
curl -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL"
|
||||
curl -H "Content-Type: application/json" -d "$payload" "$DISCORD_WEBHOOK_URL"
|
||||
Reference in New Issue
Block a user