|
| 1 | +name: Pre-release Publisher |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [prereleased] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + packages: write |
| 11 | + actions: read |
| 12 | + checks: read |
| 13 | + deployments: read |
| 14 | + discussions: read |
| 15 | + issues: read |
| 16 | + pages: read |
| 17 | + pull-requests: read |
| 18 | + repository-projects: read |
| 19 | + security-events: read |
| 20 | + statuses: read |
| 21 | + |
| 22 | +jobs: |
| 23 | + test: |
| 24 | + uses: ./.github/workflows/test.yml |
| 25 | + |
| 26 | + publish-prerelease: |
| 27 | + needs: test |
| 28 | + runs-on: ubuntu-latest |
| 29 | + steps: |
| 30 | + - name: Checkout code |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Setup Node.js |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: "20.15.1" |
| 37 | + cache: "npm" |
| 38 | + |
| 39 | + # Cache root dependencies |
| 40 | + - name: Cache root dependencies |
| 41 | + uses: actions/cache@v4 |
| 42 | + id: root-cache |
| 43 | + with: |
| 44 | + path: node_modules |
| 45 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 46 | + |
| 47 | + # Cache webview-ui dependencies |
| 48 | + - name: Cache webview-ui dependencies |
| 49 | + uses: actions/cache@v4 |
| 50 | + id: webview-cache |
| 51 | + with: |
| 52 | + path: webview-ui/node_modules |
| 53 | + key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }} |
| 54 | + |
| 55 | + - name: Install root dependencies |
| 56 | + if: steps.root-cache.outputs.cache-hit != 'true' |
| 57 | + run: npm ci |
| 58 | + |
| 59 | + - name: Install webview-ui dependencies |
| 60 | + if: steps.webview-cache.outputs.cache-hit != 'true' |
| 61 | + run: cd webview-ui && npm ci |
| 62 | + |
| 63 | + - name: Build Extension |
| 64 | + run: npm run build |
| 65 | + |
| 66 | + - name: Install Publishing Tools |
| 67 | + run: npm install -g vsce ovsx |
| 68 | + |
| 69 | + - name: Package and Publish Pre-release |
| 70 | + env: |
| 71 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 72 | + OVSX_PAT: ${{ secrets.OVSX_PAT }} |
| 73 | + run: | |
| 74 | + current_package_version=$(node -p "require('./package.json').version") |
| 75 | + vsce package |
| 76 | + vsce publish --pre-release -p ${{ secrets.VSCE_PAT }} |
| 77 | + echo "Successfully published pre-release version $current_package_version to VS Code Marketplace" |
| 78 | +
|
| 79 | + - name: Create GitHub Pre-release |
| 80 | + uses: softprops/action-gh-release@v1 |
| 81 | + with: |
| 82 | + files: "*.vsix" |
| 83 | + generate_release_notes: true |
| 84 | + prerelease: true |
| 85 | + env: |
| 86 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments