| 1 | name: Create VS Code main release draft |
| 2 | on: |
| 3 | # Not using this now because making drafts was just noisy. Will be useful when we are ready for automated releases. |
| 4 | # schedule: |
| 5 | # # Runs at 7 AM PST (15:00 UTC) every Friday |
| 6 | # - cron: "0 15 * * 5" |
| 7 | workflow_dispatch: |
| 8 | # Allows manual triggering |
| 9 | |
| 10 | jobs: |
| 11 | version-bump: |
| 12 | runs-on: ubuntu-latest |
| 13 | steps: |
| 14 | - name: Checkout repository |
| 15 | uses: actions/checkout@v5 |
| 16 | with: |
| 17 | fetch-depth: 0 # Fetch all history and tags |
| 18 | |
| 19 | - name: Setup GitHub CLI |
| 20 | run: | |
| 21 | gh auth login --with-token <<< "${{ github.token }}" |
| 22 | |
| 23 | - name: Use Node.js from .nvmrc |
| 24 | uses: actions/setup-node@v5 |
| 25 | with: |
| 26 | node-version-file: ".nvmrc" |
| 27 | |
| 28 | - name: Find and process version tags |
| 29 | run: | |
| 30 | echo "Starting version bump process..." |
| 31 | |
| 32 | # Find last v1.1.x-vscode tag that's at least 6 days old |
| 33 | CURRENT_TIMESTAMP=$(date +%s) |
| 34 | SIX_DAYS_AGO=$((CURRENT_TIMESTAMP - 6*24*60*60)) |
| 35 | echo "Current timestamp: $(date -d @${CURRENT_TIMESTAMP})" |
| 36 | echo "Six days ago: $(date -d @${SIX_DAYS_AGO})" |
| 37 | |
| 38 | echo "Looking for v1.1.x-vscode tags..." |
| 39 | git for-each-ref --sort=-creatordate --format '%(refname:short) %(creatordate:iso)' refs/tags | grep 'v1\.1\.[0-9]\+-vscode' || echo "No matching tags found" |
| 40 | |
| 41 | LAST_1_1_TAG=$(git for-each-ref --sort=-creatordate --format '%(refname:short) %(creatordate:unix)' refs/tags \ |
| 42 | | grep 'v1\.1\.[0-9]\+-vscode' \ |
| 43 | | while read tag timestamp; do |
| 44 | if [ $timestamp -le $SIX_DAYS_AGO ]; then |
| 45 | echo ${tag% *} |
| 46 | break |
| 47 | fi |
| 48 | done) |
| 49 | |
| 50 | echo "Selected v1.1.x tag: $LAST_1_1_TAG" |
| 51 | if [ -z "$LAST_1_1_TAG" ]; then |
| 52 | echo "::error::No suitable v1.1.x-vscode tag found" |
| 53 | exit 1 |
| 54 | fi |
| 55 | |
| 56 | # Find last v1.0.y-vscode tag |
| 57 | echo "Looking for v1.0.y-vscode tags..." |
| 58 | git tag --sort=-v:refname | grep '^v1\.0\.[0-9]\+-vscode' || echo "No matching tags found" |
| 59 | |
| 60 | LAST_1_0_TAG=$(git tag --sort=-v:refname | grep '^v1\.0\.[0-9]\+-vscode' | head -n1) |
| 61 | echo "Selected v1.0.y tag: $LAST_1_0_TAG" |
| 62 | if [ -z "$LAST_1_0_TAG" ]; then |
| 63 | echo "::error::No v1.0.y-vscode tag found" |
| 64 | exit 1 |
| 65 | fi |
| 66 | |
| 67 | # Extract the y number and increment it |
| 68 | Y_NUMBER=$(echo $LAST_1_0_TAG | sed 's/v1\.0\.\([0-9]\+\)-vscode/\1/') |
| 69 | NEXT_Y=$((Y_NUMBER + 1)) |
| 70 | NEW_BRANCH="v1.0.${NEXT_Y}-vscode" |
| 71 | NEW_VERSION="1.0.${NEXT_Y}" |
| 72 | echo "Current Y number: $Y_NUMBER" |
| 73 | echo "Next Y number: $NEXT_Y" |
| 74 | echo "New branch name: $NEW_BRANCH" |
| 75 | echo "New version: $NEW_VERSION" |
| 76 | |
| 77 | # Create new branch from the v1.1.x tag |
| 78 | echo "Creating new branch from $LAST_1_1_TAG..." |
| 79 | git checkout $LAST_1_1_TAG |
| 80 | git checkout -b $NEW_BRANCH |
| 81 | |
| 82 | # Update the version in package.json |
| 83 | echo "Current package.json version:" |
| 84 | cat extensions/vscode/package.json | grep version |
| 85 | |
| 86 | echo "Updating version in package.json..." |
| 87 | jq ".version = \"$NEW_VERSION\"" extensions/vscode/package.json > temp.json && mv temp.json extensions/vscode/package.json |
| 88 | |
| 89 | echo "New package.json version:" |
| 90 | cat extensions/vscode/package.json | grep version |
| 91 | |
| 92 | # Configure git |
| 93 | echo "Configuring git..." |
| 94 | git config user.name "GitHub Actions Bot" |
| 95 | git config user.email "actions@github.com" |
| 96 | |
| 97 | # Commit and push changes |
| 98 | echo "Committing changes..." |
| 99 | git add extensions/vscode/package.json |
| 100 | git commit -m "Bump VS Code extension to ${NEW_VERSION}" |
| 101 | |
| 102 | echo "Pushing branch to origin..." |
| 103 | git push origin $NEW_BRANCH |
| 104 | |
| 105 | # Add release creation |
| 106 | echo "Creating draft release..." |
| 107 | gh release create "${NEW_BRANCH}" \ |
| 108 | --title "${NEW_BRANCH}" \ |
| 109 | --generate-notes \ |
| 110 | --draft \ |
| 111 | --latest \ |
| 112 | --notes-start-tag "${LAST_1_0_TAG}" |
| 113 | |
| 114 | echo "Version bump process completed successfully!" |
| 115 | |
| 116 | - name: Check for errors |
| 117 | if: failure() |
| 118 | run: | |
| 119 | echo "::error::Failed to process version tags and create new branch" |
| 120 | echo "Last few lines of git log:" |
| 121 | git log -n 5 --oneline |
| 122 | echo "Current git status:" |
| 123 | git status |
| 124 | echo "Current branches:" |
| 125 | git branch -a |