mirror of
https://github.com/stackblitz/bolt.new
synced 2025-02-06 04:48:04 +00:00
imporoved version for versioning system
This commit is contained in:
parent
daab6e8ead
commit
ddf4319182
72
.github/workflows/update-stable.yml
vendored
72
.github/workflows/update-stable.yml
vendored
@ -10,28 +10,33 @@ jobs:
|
|||||||
update-stable:
|
update-stable:
|
||||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'stable-release')
|
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'stable-release')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Configure Git
|
- name: Configure Git
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name 'GitHub Action'
|
git config --global user.name 'github-actions[bot]'
|
||||||
git config --global user.email 'action@github.com'
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Determine Version Bump
|
- name: Determine Version Bump
|
||||||
id: version_bump
|
id: version_bump
|
||||||
run: |
|
run: |
|
||||||
if contains(github.event.pull_request.labels.*.name, 'major')
|
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'major') }}" == "true" ]]; then
|
||||||
echo "bump=major" >> $GITHUB_OUTPUT
|
echo "bump=major" >> $GITHUB_OUTPUT
|
||||||
elif contains(github.event.pull_request.labels.*.name, 'minor')
|
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'minor') }}" == "true" ]]; then
|
||||||
echo "bump=minor" >> $GITHUB_OUTPUT
|
echo "bump=minor" >> $GITHUB_OUTPUT
|
||||||
else
|
else
|
||||||
echo "bump=patch" >> $GITHUB_OUTPUT
|
echo "bump=patch" >> $GITHUB_OUTPUT
|
||||||
@ -43,17 +48,19 @@ jobs:
|
|||||||
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
||||||
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Install semver
|
||||||
|
run: npm install -g semver
|
||||||
|
|
||||||
- name: Bump Version
|
- name: Bump Version
|
||||||
id: bump_version
|
id: bump_version
|
||||||
run: |
|
run: |
|
||||||
npm install -g semver
|
|
||||||
NEW_VERSION=$(semver -i ${{ steps.version_bump.outputs.bump }} ${{ steps.current_version.outputs.version }})
|
NEW_VERSION=$(semver -i ${{ steps.version_bump.outputs.bump }} ${{ steps.current_version.outputs.version }})
|
||||||
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Update Package.json
|
- name: Update Package.json
|
||||||
run: |
|
run: |
|
||||||
NEW_VERSION=${{ steps.bump_version.outputs.new_version }}
|
NEW_VERSION=${{ steps.bump_version.outputs.new_version }}
|
||||||
npm version $NEW_VERSION --no-git-tag-version
|
npm version $NEW_VERSION --no-git-tag-version --allow-same-version
|
||||||
|
|
||||||
- name: Generate Changelog
|
- name: Generate Changelog
|
||||||
id: changelog
|
id: changelog
|
||||||
@ -61,19 +68,23 @@ jobs:
|
|||||||
# Get the latest tag
|
# Get the latest tag
|
||||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
||||||
|
|
||||||
|
# Start changelog file
|
||||||
|
echo "# Release v${{ steps.bump_version.outputs.new_version }}" > changelog.md
|
||||||
|
echo "" >> changelog.md
|
||||||
|
|
||||||
if [ -z "$LATEST_TAG" ]; then
|
if [ -z "$LATEST_TAG" ]; then
|
||||||
# If no tags exist, get all commits
|
|
||||||
echo "### 🎉 First Release" >> changelog.md
|
echo "### 🎉 First Release" >> changelog.md
|
||||||
echo "" >> changelog.md
|
echo "" >> changelog.md
|
||||||
|
COMPARE_BASE="$(git rev-list --max-parents=0 HEAD)"
|
||||||
else
|
else
|
||||||
# Get commits since last tag
|
|
||||||
echo "### 🔄 Changes since $LATEST_TAG" >> changelog.md
|
echo "### 🔄 Changes since $LATEST_TAG" >> changelog.md
|
||||||
echo "" >> changelog.md
|
echo "" >> changelog.md
|
||||||
|
COMPARE_BASE="$LATEST_TAG"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Function to extract conventional commit type
|
# Function to extract conventional commit type
|
||||||
get_commit_type() {
|
get_commit_type() {
|
||||||
if [[ $1 =~ ^feat: ]]; then echo "✨ Features";
|
if [[ $1 =~ ^feat:|^feature: ]]; then echo "✨ Features";
|
||||||
elif [[ $1 =~ ^fix: ]]; then echo "🐛 Bug Fixes";
|
elif [[ $1 =~ ^fix: ]]; then echo "🐛 Bug Fixes";
|
||||||
elif [[ $1 =~ ^docs: ]]; then echo "📚 Documentation";
|
elif [[ $1 =~ ^docs: ]]; then echo "📚 Documentation";
|
||||||
elif [[ $1 =~ ^style: ]]; then echo "💎 Styles";
|
elif [[ $1 =~ ^style: ]]; then echo "💎 Styles";
|
||||||
@ -88,26 +99,28 @@ jobs:
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Generate categorized changelog
|
# Generate categorized changelog
|
||||||
CATEGORIES=()
|
declare -A CATEGORIES
|
||||||
declare -A COMMITS_BY_CATEGORY
|
declare -A COMMITS_BY_CATEGORY
|
||||||
|
|
||||||
# Get commits since last tag or all commits if no tag exists
|
# Get commits since last tag or all commits if no tag exists
|
||||||
if [ -z "$LATEST_TAG" ]; then
|
while IFS= read -r commit_line; do
|
||||||
git log --pretty=format:"%s" > temp_commits.txt
|
HASH=$(echo "$commit_line" | cut -d'|' -f1)
|
||||||
else
|
MSG=$(echo "$commit_line" | cut -d'|' -f2)
|
||||||
git log ${LATEST_TAG}..HEAD --pretty=format:"%s" > temp_commits.txt
|
PR_NUM=$(echo "$commit_line" | cut -d'|' -f3)
|
||||||
fi
|
|
||||||
|
|
||||||
while IFS= read -r commit; do
|
CATEGORY=$(get_commit_type "$MSG")
|
||||||
CATEGORY=$(get_commit_type "$commit")
|
CATEGORIES["$CATEGORY"]=1
|
||||||
if [[ ! " ${CATEGORIES[@]} " =~ " ${CATEGORY} " ]]; then
|
|
||||||
CATEGORIES+=("$CATEGORY")
|
# Format commit message with PR link if available
|
||||||
|
if [ -n "$PR_NUM" ]; then
|
||||||
|
COMMITS_BY_CATEGORY["$CATEGORY"]+="- ${MSG#*: } ([#$PR_NUM](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/$PR_NUM))"$'\n'
|
||||||
|
else
|
||||||
|
COMMITS_BY_CATEGORY["$CATEGORY"]+="- ${MSG#*: }"$'\n'
|
||||||
fi
|
fi
|
||||||
COMMITS_BY_CATEGORY["$CATEGORY"]+="- ${commit#*: }"$'\n'
|
done < <(git log "${COMPARE_BASE}..HEAD" --pretty=format:"%H|%s|%(trailers:key=PR-Number,valueonly)" --reverse)
|
||||||
done < temp_commits.txt
|
|
||||||
|
|
||||||
# Write categorized commits to changelog
|
# Write categorized commits to changelog
|
||||||
for category in "${CATEGORIES[@]}"; do
|
for category in "✨ Features" "🐛 Bug Fixes" "📚 Documentation" "💎 Styles" "♻️ Code Refactoring" "⚡️ Performance Improvements" "✅ Tests" "🛠️ Build System" "⚙️ CI" "🔧 Chores" "🔍 Other Changes"; do
|
||||||
if [ -n "${COMMITS_BY_CATEGORY[$category]}" ]; then
|
if [ -n "${COMMITS_BY_CATEGORY[$category]}" ]; then
|
||||||
echo "#### $category" >> changelog.md
|
echo "#### $category" >> changelog.md
|
||||||
echo "" >> changelog.md
|
echo "" >> changelog.md
|
||||||
@ -116,7 +129,10 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
rm temp_commits.txt
|
# Add compare link if not first release
|
||||||
|
if [ -n "$LATEST_TAG" ]; then
|
||||||
|
echo "**Full Changelog**: [\`$LATEST_TAG..v${{ steps.bump_version.outputs.new_version }}\`](${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/compare/$LATEST_TAG...v${{ steps.bump_version.outputs.new_version }})" >> changelog.md
|
||||||
|
fi
|
||||||
|
|
||||||
# Save changelog content for the release
|
# Save changelog content for the release
|
||||||
CHANGELOG_CONTENT=$(cat changelog.md)
|
CHANGELOG_CONTENT=$(cat changelog.md)
|
||||||
@ -132,8 +148,9 @@ jobs:
|
|||||||
|
|
||||||
- name: Update Stable Branch
|
- name: Update Stable Branch
|
||||||
run: |
|
run: |
|
||||||
git checkout stable
|
# Ensure stable branch exists
|
||||||
git merge main
|
git checkout stable 2>/dev/null || git checkout -b stable
|
||||||
|
git merge main --no-ff -m "chore: merge main into stable for version ${{ steps.bump_version.outputs.new_version }}"
|
||||||
git push origin stable
|
git push origin stable
|
||||||
|
|
||||||
- name: Create and Push Tag
|
- name: Create and Push Tag
|
||||||
@ -147,8 +164,7 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
VERSION="v${{ steps.bump_version.outputs.new_version }}"
|
VERSION="v${{ steps.bump_version.outputs.new_version }}"
|
||||||
|
|
||||||
# Create release with generated changelog
|
|
||||||
gh release create "$VERSION" \
|
gh release create "$VERSION" \
|
||||||
--title "Release $VERSION" \
|
--title "Release $VERSION" \
|
||||||
--notes "${{ steps.changelog.outputs.content }}"
|
--notes "${{ steps.changelog.outputs.content }}" \
|
||||||
|
--target stable
|
Loading…
Reference in New Issue
Block a user