promote: stable v1.14.18 #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Build Artifact | |
| on: | |
| pull_request: | |
| branches: [master] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| build-artifact: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| registry-url: https://registry.npmjs.org | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Publish to npm with PR tag | |
| run: | | |
| PR_NUMBER="${{ github.event.pull_request.number }}" | |
| RUN_NUMBER="${{ github.run_number }}" | |
| BASE_VERSION=$(node -p "require('./package.json').version") | |
| # Strip any existing prerelease suffix | |
| BASE_VERSION=$(echo "$BASE_VERSION" | sed 's/-.*//') | |
| PR_VERSION="${BASE_VERSION}-pr.${PR_NUMBER}.${RUN_NUMBER}" | |
| echo "Publishing version $PR_VERSION with tag pr-${PR_NUMBER}" | |
| npm version "$PR_VERSION" --no-git-tag-version | |
| npm publish --tag "pr-${PR_NUMBER}" --access public --ignore-scripts | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create installable tarball | |
| run: | | |
| npm pack | |
| PR_NUM="${{ github.event.pull_request.number }}" | |
| TARBALL=$(ls opencode-acp-*.tgz | head -1) | |
| if [ -n "$PR_NUM" ] && [ -n "$TARBALL" ]; then | |
| cp "$TARBALL" "opencode-acp-pr${PR_NUM}.tgz" | |
| fi | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: opencode-acp-pr-${{ github.event.pull_request.number }} | |
| path: | | |
| opencode-acp-pr*.tgz | |
| dist/ | |
| retention-days: 30 | |
| - name: Comment on PR with install instructions | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const sha = context.payload.pull_request.head.sha.slice(0, 7); | |
| const branch = context.payload.pull_request.head.ref; | |
| const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
| const body = [ | |
| '## 📦 Built Plugin Artifact', | |
| '', | |
| `**Branch:** \`${branch}\` (${sha})`, | |
| '', | |
| '### Option A — Install from npm PR tag (recommended)', | |
| '', | |
| '```bash', | |
| 'opencode plugin opencode-acp@pr-' + prNumber + ' --global', | |
| '```', | |
| '', | |
| 'Each push to this PR publishes a new version under the `pr-' + prNumber + '` npm tag.', | |
| '', | |
| '### Option B — Install from GitHub', | |
| '', | |
| '```bash', | |
| 'opencode plugin "github:ranxianglei/opencode-acp#' + branch + '" --global', | |
| '```', | |
| '', | |
| '### Option C — Download artifact', | |
| '', | |
| `1. Download the artifact from the [Actions run](${runUrl})`, | |
| '2. Extract the tarball and install:', | |
| '', | |
| '```bash', | |
| 'tar xzf opencode-acp-pr' + prNumber + '.tgz', | |
| 'cp -r package/dist ~/.cache/opencode/packages/opencode-acp@latest/node_modules/opencode-acp/dist', | |
| '```', | |
| '', | |
| '3. **Restart opencode** to pick up changes.', | |
| '', | |
| '---', | |
| '*This comment is automatically updated on each push.*', | |
| ].join('\n'); | |
| // Find and update existing comment, or create new one | |
| const comments = await github.rest.issues.listComments({ | |
| ...context.repo, | |
| issue_number: prNumber, | |
| }); | |
| const existing = comments.data.find(c => | |
| c.user.type === 'Bot' && c.body.includes('📦 Built Plugin Artifact') | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| ...context.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| ...context.repo, | |
| issue_number: prNumber, | |
| body, | |
| }); | |
| } |