Merge pull request #5003 from continuedev/nate/auto-bump

Nate/auto-bump
This commit is contained in:
Nate Sesti 2025-04-05 15:59:07 -07:00 • committed by GitHub
commit ac6b4526a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 246 additions and 3 deletions

99
.github/workflows/auto-release.yml vendored Normal file
View file

@ -0,0 +1,99 @@
name: Create Automatic Release
on:
schedule:
- cron: "0 17 * * 1,3,5" # Run at 9am PST (17:00 UTC) on Monday, Wednesday, Friday
workflow_dispatch: # Keep manual trigger option
jobs:
create-vscode-release:
runs-on: ubuntu-latest
permissions:
contents: write # Needed for creating releases
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Important for getting all tags and commits
- name: Get latest tag
id: get_latest_tag
run: |
# Get the latest tag ending in -vscode or default to v1.1.0-vscode if none exists
latest_tag=$(git tag --sort=-creatordate | grep -E "-vscode$" | head -n 1 || echo "v1.1.0-vscode")
echo "Latest tag: $latest_tag"
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
- name: Generate next version
id: generate_version
run: |
# Extract version numbers (handle the -vscode suffix)
version=${LATEST_TAG#v} # Remove v prefix
version=${version%-vscode} # Remove -vscode suffix
IFS='.' read -ra VERSION_PARTS <<< "$version"
# Increment patch version
((VERSION_PARTS[2]++))
# Create new version string with -vscode suffix
new_version="v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}-vscode"
echo "New version will be: $new_version"
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Create a new draft release with auto-generated release notes
gh release create "$NEW_VERSION" \
--generate-notes \
--title "$NEW_VERSION" \
--draft \
--latest
--prerelease
create-jetbrains-release:
runs-on: ubuntu-latest
permissions:
contents: write # Needed for creating releases
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Important for getting all tags and commits
- name: Get latest tag
id: get_latest_tag
run: |
# Get the latest tag ending in -jetbrains or default to v1.1.0-jetbrains if none exists
latest_tag=$(git tag --sort=-creatordate | grep -E "-jetbrains$" | head -n 1 || echo "v1.1.0-jetbrains")
echo "Latest tag: $latest_tag"
echo "LATEST_TAG=$latest_tag" >> $GITHUB_ENV
- name: Generate next version
id: generate_version
run: |
# Extract version numbers (handle the -jetbrains suffix)
version=${LATEST_TAG#v} # Remove v prefix
version=${version%-jetbrains} # Remove -jetbrains suffix
IFS='.' read -ra VERSION_PARTS <<< "$version"
# Increment patch version
((VERSION_PARTS[2]++))
# Create new version string with -jetbrains suffix
new_version="v${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}-jetbrains"
echo "New version will be: $new_version"
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
- name: Create Release
env:
GH_TOKEN: ${{ github.token }}
run: |
# Create a new draft release with auto-generated release notes
gh release create "$NEW_VERSION" \
--generate-notes \
--title "$NEW_VERSION" \
--draft \
--latest
--prerelease

View file

@ -1,4 +1,4 @@
name: Publish Preview Extension
name: Publish Pre-release Extension
on:
release:
@ -207,6 +207,7 @@ jobs:
if: github.event_name != 'workflow_dispatch' || github.event.inputs.publish_build == 'true'
permissions:
contents: write
pull-requests: write
steps:
# 0. Setup git
- name: Checkout
@ -242,12 +243,44 @@ jobs:
cd extensions/vscode
npx ovsx publish --pre-release -p ${{ secrets.VSX_REGISTRY_TOKEN }} --packagePath ../../vsix-artifacts/*.vsix
# 4. Update the package.json version and push changes
# 4. Create PR with version bump
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Create PR branch
run: |
BRANCH_NAME="chore/bump-vscode-version-$(date +%Y%m%d-%H%M%S)"
git checkout -b $BRANCH_NAME
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Bump version in package.json
run: |
cd extensions/vscode
npm version patch --no-git-tag-version
VERSION=$(node -p "require('./package.json').version")
echo "NEW_VERSION=$VERSION" >> $GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.CI_GITHUB_TOKEN }}
commit-message: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}"
title: "chore: bump vscode extension version to ${{ env.NEW_VERSION }}"
body: |
Automated PR to bump the VS Code extension version after successful pre-release publication.
- Bumped version in extensions/vscode/package.json to ${{ env.NEW_VERSION }}
branch: ${{ env.BRANCH_NAME }}
base: main
delete-branch: true
# 5. Update version in package.json
# - name: Update version in package.json
# run: |
# cd extensions/vscode
# npm version patch
# - name: Commit changes
# run: |
# git config --local user.email "action@github.com"

View file

@ -0,0 +1,111 @@
name: VS Code Extension Version Bump
on:
schedule:
# Runs at 7 AM PST (15:00 UTC) every Friday
- cron: "0 15 * * 5"
workflow_dispatch:
# Allows manual triggering
jobs:
version-bump:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history and tags
- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- name: Find and process version tags
run: |
echo "Starting version bump process..."
# Find last v1.1.x-vscode tag that's at least 6 days old
CURRENT_TIMESTAMP=$(date +%s)
SIX_DAYS_AGO=$((CURRENT_TIMESTAMP - 6*24*60*60))
echo "Current timestamp: $(date -d @${CURRENT_TIMESTAMP})"
echo "Six days ago: $(date -d @${SIX_DAYS_AGO})"
echo "Looking for v1.1.x-vscode tags..."
git for-each-ref --sort=-creatordate --format '%(refname:short) %(creatordate:iso)' refs/tags | grep 'v1\.1\.[0-9]\+-vscode' || echo "No matching tags found"
LAST_1_1_TAG=$(git for-each-ref --sort=-creatordate --format '%(refname:short) %(creatordate:unix)' refs/tags \
| grep 'v1\.1\.[0-9]\+-vscode' \
| while read tag timestamp; do
if [ $timestamp -le $SIX_DAYS_AGO ]; then
echo ${tag% *}
break
fi
done)
echo "Selected v1.1.x tag: $LAST_1_1_TAG"
if [ -z "$LAST_1_1_TAG" ]; then
echo "::error::No suitable v1.1.x-vscode tag found"
exit 1
fi
# Find last v1.0.y-vscode tag
echo "Looking for v1.0.y-vscode tags..."
git tag --sort=-v:refname | grep '^v1\.0\.[0-9]\+-vscode' || echo "No matching tags found"
LAST_1_0_TAG=$(git tag --sort=-v:refname | grep '^v1\.0\.[0-9]\+-vscode' | head -n1)
echo "Selected v1.0.y tag: $LAST_1_0_TAG"
if [ -z "$LAST_1_0_TAG" ]; then
echo "::error::No v1.0.y-vscode tag found"
exit 1
fi
# Extract the y number and increment it
Y_NUMBER=$(echo $LAST_1_0_TAG | sed 's/v1\.0\.\([0-9]\+\)-vscode/\1/')
NEXT_Y=$((Y_NUMBER + 1))
NEW_BRANCH="v1.0.${NEXT_Y}-vscode"
NEW_VERSION="1.0.${NEXT_Y}"
echo "Current Y number: $Y_NUMBER"
echo "Next Y number: $NEXT_Y"
echo "New branch name: $NEW_BRANCH"
echo "New version: $NEW_VERSION"
# Create new branch from the v1.1.x tag
echo "Creating new branch from $LAST_1_1_TAG..."
git checkout $LAST_1_1_TAG
git checkout -b $NEW_BRANCH
# Update the version in package.json
echo "Current package.json version:"
cat extensions/vscode/package.json | grep version
echo "Updating version in package.json..."
jq ".version = \"$NEW_VERSION\"" extensions/vscode/package.json > temp.json && mv temp.json extensions/vscode/package.json
echo "New package.json version:"
cat extensions/vscode/package.json | grep version
# Configure git
echo "Configuring git..."
git config user.name "GitHub Actions Bot"
git config user.email "actions@github.com"
# Commit and push changes
echo "Committing changes..."
git add extensions/vscode/package.json
git commit -m "Bump VS Code extension to ${NEW_VERSION}"
echo "Pushing branch to origin..."
git push origin $NEW_BRANCH
echo "Version bump process completed successfully!"
- name: Check for errors
if: failure()
run: |
echo "::error::Failed to process version tags and create new branch"
echo "Last few lines of git log:"
git log -n 5 --oneline
echo "Current git status:"
git status
echo "Current branches:"
git branch -a