mirror of
https://github.com/stackblitz/bolt.new
synced 2025-02-06 04:48:04 +00:00
Merge pull request #701 from thecodacus/auto-versioning #release
chore: Adding workflow
This commit is contained in:
commit
6cb536a9a3
31
.github/workflows/pr-release-validation.yaml
vendored
Normal file
31
.github/workflows/pr-release-validation.yaml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
name: PR Validation
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened, labeled, unlabeled]
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate PR Labels
|
||||||
|
run: |
|
||||||
|
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'stable-release') }}" == "true" ]]; then
|
||||||
|
echo "✓ PR has stable-release label"
|
||||||
|
|
||||||
|
# Check version bump labels
|
||||||
|
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'major') }}" == "true" ]]; then
|
||||||
|
echo "✓ Major version bump requested"
|
||||||
|
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'minor') }}" == "true" ]]; then
|
||||||
|
echo "✓ Minor version bump requested"
|
||||||
|
else
|
||||||
|
echo "✓ Patch version bump will be applied"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "This PR doesn't have the stable-release label. No release will be created."
|
||||||
|
fi
|
71
.github/workflows/update-stable.yml
vendored
71
.github/workflows/update-stable.yml
vendored
@ -1,8 +1,7 @@
|
|||||||
name: Update Stable Branch
|
name: Update Stable Branch
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
push:
|
||||||
types: [closed]
|
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
@ -10,18 +9,15 @@ permissions:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-stable:
|
prepare-release:
|
||||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'stable-release')
|
if: contains(github.event.head_commit.message, '#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-actions[bot]'
|
git config --global user.name 'github-actions[bot]'
|
||||||
@ -52,17 +48,6 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pnpm-store-
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- name: Determine Version Bump
|
|
||||||
id: version_bump
|
|
||||||
run: |
|
|
||||||
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'major') }}" == "true" ]]; then
|
|
||||||
echo "bump=major" >> $GITHUB_OUTPUT
|
|
||||||
elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'minor') }}" == "true" ]]; then
|
|
||||||
echo "bump=minor" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "bump=patch" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Get Current Version
|
- name: Get Current Version
|
||||||
id: current_version
|
id: current_version
|
||||||
run: |
|
run: |
|
||||||
@ -72,6 +57,18 @@ jobs:
|
|||||||
- name: Install semver
|
- name: Install semver
|
||||||
run: pnpm add -g semver
|
run: pnpm add -g semver
|
||||||
|
|
||||||
|
- name: Determine Version Bump
|
||||||
|
id: version_bump
|
||||||
|
run: |
|
||||||
|
COMMIT_MSG="${{ github.event.head_commit.message }}"
|
||||||
|
if [[ $COMMIT_MSG =~ "#release:major" ]]; then
|
||||||
|
echo "bump=major" >> $GITHUB_OUTPUT
|
||||||
|
elif [[ $COMMIT_MSG =~ "#release:minor" ]]; then
|
||||||
|
echo "bump=minor" >> $GITHUB_OUTPUT
|
||||||
|
else
|
||||||
|
echo "bump=patch" >> $GITHUB_OUTPUT
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Bump Version
|
- name: Bump Version
|
||||||
id: bump_version
|
id: bump_version
|
||||||
run: |
|
run: |
|
||||||
@ -161,32 +158,30 @@ jobs:
|
|||||||
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
|
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
|
||||||
echo "EOF" >> $GITHUB_OUTPUT
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Commit Version Update
|
- name: Commit and Tag Release
|
||||||
run: |
|
run: |
|
||||||
git pull
|
git pull
|
||||||
git add package.json pnpm-lock.yaml changelog.md
|
git add package.json pnpm-lock.yaml changelog.md
|
||||||
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }}"
|
git commit -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
|
||||||
|
git tag "v${{ steps.bump_version.outputs.new_version }}"
|
||||||
git push
|
git push
|
||||||
|
git push --tags
|
||||||
|
|
||||||
- name: Update Stable Branch
|
- name: Update Stable Branch
|
||||||
run: |
|
run: |
|
||||||
# Ensure stable branch exists
|
if ! git checkout stable 2>/dev/null; then
|
||||||
git checkout stable 2>/dev/null || git checkout -b stable
|
echo "Creating new stable branch..."
|
||||||
git merge main --no-ff -m "chore: merge main into stable for version ${{ steps.bump_version.outputs.new_version }}"
|
git checkout -b stable
|
||||||
git push --set-upstream origin stable
|
fi
|
||||||
|
git merge main --no-ff -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
|
||||||
|
git push --set-upstream origin stable --force
|
||||||
|
|
||||||
- name: Create and Push Tag
|
- name: Create GitHub Release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
VERSION="v${{ steps.bump_version.outputs.new_version }}"
|
VERSION="v${{ steps.bump_version.outputs.new_version }}"
|
||||||
git tag -a "$VERSION" -m "Release $VERSION"
|
gh release create "$VERSION" \
|
||||||
git push origin "$VERSION"
|
--title "Release $VERSION" \
|
||||||
|
--notes "${{ steps.changelog.outputs.content }}" \
|
||||||
# - name: Create GitHub Release
|
--target stable
|
||||||
# env:
|
|
||||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# run: |
|
|
||||||
# VERSION="v${{ steps.bump_version.outputs.new_version }}"
|
|
||||||
# gh release create "$VERSION" \
|
|
||||||
# --title "Release $VERSION" \
|
|
||||||
# --notes "${{ steps.changelog.outputs.content }}" \
|
|
||||||
# --target stable
|
|
Loading…
Reference in New Issue
Block a user