|
1 | | -name: Publish Extension |
| 1 | +name: Publish Stable Extension |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request: |
5 | | - types: [closed] |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
6 | 7 | workflow_dispatch: |
7 | 8 |
|
8 | | -env: |
9 | | - GIT_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || 'main' }} |
10 | | - |
11 | 9 | jobs: |
12 | | - publish-extension: |
| 10 | + publish-stable: |
13 | 11 | runs-on: ubuntu-latest |
14 | 12 | permissions: |
15 | | - contents: write # Required for pushing tags. |
16 | | - if: > |
17 | | - ( github.event_name == 'pull_request' && |
18 | | - github.event.pull_request.base.ref == 'main' && |
19 | | - contains(github.event.pull_request.title, 'Changeset version bump') ) || |
20 | | - github.event_name == 'workflow_dispatch' |
| 13 | + contents: write |
| 14 | + |
21 | 15 | steps: |
22 | 16 | - name: Checkout code |
23 | 17 | uses: actions/checkout@v4 |
24 | | - with: |
25 | | - ref: ${{ env.GIT_REF }} |
| 18 | + |
26 | 19 | - name: Setup Node.js and pnpm |
27 | 20 | uses: ./.github/actions/setup-node-pnpm |
28 | | - - name: Configure Git |
| 21 | + with: |
| 22 | + install-args: "--frozen-lockfile" |
| 23 | + |
| 24 | + - name: Validate package identity |
29 | 25 | run: | |
30 | | - git config user.name "github-actions[bot]" |
31 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
32 | | - - name: Create .env file |
33 | | - run: echo "POSTHOG_API_KEY=${{ secrets.POSTHOG_API_KEY }}" >> .env |
34 | | - - name: Package Extension |
| 26 | + package_name=$(node -p "require('./src/package.json').name") |
| 27 | + publisher=$(node -p "require('./src/package.json').publisher") |
| 28 | +
|
| 29 | + test "$package_name" = "zoo-code" |
| 30 | + test "$publisher" = "ZooCodeOrganization" |
| 31 | +
|
| 32 | + - name: Validate release tag |
| 33 | + if: github.event_name == 'push' |
35 | 34 | run: | |
36 | | - current_package_version=$(node -p "require('./src/package.json').version") |
37 | | - pnpm vsix |
38 | | -
|
39 | | - # Save VSIX contents to a temporary file to avoid broken pipe issues. |
40 | | - unzip -l bin/roo-cline-${current_package_version}.vsix > /tmp/roo-code-vsix-contents.txt |
41 | | -
|
42 | | - # Check for required files. |
43 | | - grep -q "extension/package.json" /tmp/roo-code-vsix-contents.txt || exit 1 |
44 | | - grep -q "extension/package.nls.json" /tmp/roo-code-vsix-contents.txt || exit 1 |
45 | | - grep -q "extension/dist/extension.js" /tmp/roo-code-vsix-contents.txt || exit 1 |
46 | | - grep -q "extension/webview-ui/audio/celebration.wav" /tmp/roo-code-vsix-contents.txt || exit 1 |
47 | | - grep -q "extension/webview-ui/build/assets/index.js" /tmp/roo-code-vsix-contents.txt || exit 1 |
48 | | - grep -q "extension/assets/codicons/codicon.ttf" /tmp/roo-code-vsix-contents.txt || exit 1 |
49 | | - grep -q "extension/assets/vscode-material-icons/icons/3d.svg" /tmp/roo-code-vsix-contents.txt || exit 1 |
50 | | - grep -q ".env" /tmp/roo-code-vsix-contents.txt || exit 1 |
51 | | - |
52 | | - # Clean up temporary file. |
53 | | - rm /tmp/roo-code-vsix-contents.txt |
54 | | - - name: Create and Push Git Tag |
| 35 | + package_version=$(node -p "require('./src/package.json').version") |
| 36 | + tag_version="${GITHUB_REF_NAME#v}" |
| 37 | +
|
| 38 | + if [ "$package_version" != "$tag_version" ]; then |
| 39 | + echo "Tag v${tag_version} does not match src/package.json version ${package_version}." |
| 40 | + exit 1 |
| 41 | + fi |
| 42 | +
|
| 43 | + - name: Build workspace packages |
55 | 44 | run: | |
56 | | - current_package_version=$(node -p "require('./src/package.json').version") |
57 | | - git tag -a "v${current_package_version}" -m "Release v${current_package_version}" |
58 | | - git push origin "v${current_package_version}" --no-verify |
59 | | - echo "Successfully created and pushed git tag v${current_package_version}" |
60 | | - - name: Publish Extension |
| 45 | + pnpm --filter @roo-code/build build |
| 46 | + pnpm --filter @roo-code/vscode-webview build |
| 47 | +
|
| 48 | + - name: Package extension |
| 49 | + env: |
| 50 | + POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} |
| 51 | + run: | |
| 52 | + package_version=$(node -p "require('./src/package.json').version") |
| 53 | + pnpm --filter ./src vsix |
| 54 | +
|
| 55 | + vsix_path="bin/zoo-code-${package_version}.vsix" |
| 56 | + test -f "$vsix_path" |
| 57 | +
|
| 58 | + unzip -l "$vsix_path" > /tmp/zoo-code-vsix-contents.txt |
| 59 | + grep -q "extension/package.json" /tmp/zoo-code-vsix-contents.txt |
| 60 | + grep -q "extension/package.nls.json" /tmp/zoo-code-vsix-contents.txt |
| 61 | + grep -q "extension/dist/extension.js" /tmp/zoo-code-vsix-contents.txt |
| 62 | + grep -q "extension/webview-ui/audio/celebration.wav" /tmp/zoo-code-vsix-contents.txt |
| 63 | + grep -q "extension/webview-ui/build/assets/index.js" /tmp/zoo-code-vsix-contents.txt |
| 64 | + grep -q "extension/assets/codicons/codicon.ttf" /tmp/zoo-code-vsix-contents.txt |
| 65 | + grep -q "extension/assets/vscode-material-icons/icons/3d.svg" /tmp/zoo-code-vsix-contents.txt |
| 66 | +
|
| 67 | + - name: Validate packaged manifest identity |
| 68 | + run: | |
| 69 | + package_version=$(node -p "require('./src/package.json').version") |
| 70 | + vsix_path="bin/zoo-code-${package_version}.vsix" |
| 71 | +
|
| 72 | + artifact_name=$(unzip -p "$vsix_path" extension/package.json | jq -r '.name') |
| 73 | + artifact_publisher=$(unzip -p "$vsix_path" extension/package.json | jq -r '.publisher') |
| 74 | +
|
| 75 | + test "$artifact_name" = "zoo-code" |
| 76 | + test "$artifact_publisher" = "ZooCodeOrganization" |
| 77 | +
|
| 78 | + - name: Publish to VS Code Marketplace |
61 | 79 | env: |
62 | 80 | VSCE_PAT: ${{ secrets.VSCE_PAT }} |
63 | | - OVSX_PAT: ${{ secrets.OVSX_PAT }} |
64 | 81 | run: | |
65 | | - current_package_version=$(node -p "require('./src/package.json').version") |
66 | | - pnpm --filter roo-cline publish:marketplace |
67 | | - echo "Successfully published version $current_package_version to VS Code Marketplace" |
68 | | - - name: Create GitHub Release |
| 82 | + package_version=$(node -p "require('./src/package.json').version") |
| 83 | + npx @vscode/vsce publish --packagePath "bin/zoo-code-${package_version}.vsix" |
| 84 | + echo "Published ZooCodeOrganization.zoo-code ${package_version} to VS Code Marketplace" |
| 85 | +
|
| 86 | + - name: Publish to Open VSX Registry |
69 | 87 | env: |
70 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + OVSX_PAT: ${{ secrets.OVSX_PAT }} |
71 | 89 | run: | |
72 | | - current_package_version=$(node -p "require('./src/package.json').version") |
| 90 | + package_version=$(node -p "require('./src/package.json').version") |
| 91 | + pnpm exec ovsx publish "bin/zoo-code-${package_version}.vsix" --skip-duplicate |
| 92 | + echo "Published ZooCodeOrganization.zoo-code ${package_version} to Open VSX Registry" |
73 | 93 |
|
74 | | - # Extract changelog for current version |
75 | | - echo "Extracting changelog for version ${current_package_version}" |
76 | | - changelog_content=$(sed -n "/## \\[${current_package_version}\\]/,/## \\[/p" CHANGELOG.md | sed '$d') |
| 94 | + - name: Create GitHub release |
| 95 | + env: |
| 96 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 97 | + run: | |
| 98 | + package_version=$(node -p "require('./src/package.json').version") |
| 99 | + if [ "${GITHUB_REF_TYPE:-}" = "tag" ]; then |
| 100 | + tag_name="$GITHUB_REF_NAME" |
| 101 | + else |
| 102 | + tag_name="v${package_version}" |
| 103 | + fi |
| 104 | + vsix_path="bin/zoo-code-${package_version}.vsix" |
77 | 105 |
|
78 | | - # If changelog extraction failed, use a default message |
| 106 | + changelog_content=$(awk -v version="$package_version" ' |
| 107 | + $0 ~ "^## \\[" version "\\]" { found = 1 } |
| 108 | + found && $0 == "---" { exit } |
| 109 | + found && $0 ~ "^## " && $0 !~ "^## \\[" version "\\]" { exit } |
| 110 | + found { print } |
| 111 | + ' CHANGELOG.md) |
79 | 112 | if [ -z "$changelog_content" ]; then |
80 | | - echo "Warning: No changelog section found for version ${current_package_version}" |
81 | | - changelog_content="Release v${current_package_version}" |
82 | | - else |
83 | | - echo "Found changelog section for version ${current_package_version}" |
| 113 | + changelog_content="Release ${tag_name}" |
84 | 114 | fi |
| 115 | + printf "%s\n" "$changelog_content" > /tmp/zoo-code-release-notes.md |
85 | 116 |
|
86 | | - # Create release with changelog content |
87 | | - gh release create "v${current_package_version}" \ |
88 | | - --title "Release v${current_package_version}" \ |
89 | | - --notes "$changelog_content" \ |
90 | | - --target ${{ env.GIT_REF }} \ |
91 | | - bin/roo-cline-${current_package_version}.vsix |
92 | | - echo "Successfully created GitHub Release v${current_package_version}" |
| 117 | + if gh release view "$tag_name" >/dev/null 2>&1; then |
| 118 | + gh release upload "$tag_name" "$vsix_path" --clobber |
| 119 | + else |
| 120 | + gh release create "$tag_name" \ |
| 121 | + --title "Zoo Code ${tag_name}" \ |
| 122 | + --notes-file /tmp/zoo-code-release-notes.md \ |
| 123 | + --target "$GITHUB_SHA" \ |
| 124 | + "$vsix_path" |
| 125 | + fi |
0 commit comments