Elffuss BraidHub

kikocis/continue public

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