|
| 1 | +name: Publish Extension |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "*" |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + preparation: |
| 14 | + name: ✅ Preparation |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + outputs: |
| 18 | + version: ${{ steps.extract.outputs.version }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: 🧾 Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: 🧰 Set up Node.js |
| 25 | + uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: 20 |
| 28 | + |
| 29 | + - name: 📦 Install dependencies |
| 30 | + run: yarn --frozen-lockfile |
| 31 | + |
| 32 | + - name: 🔧 Build extension |
| 33 | + run: yarn run package |
| 34 | + |
| 35 | + - name: 📦 Package extension |
| 36 | + run: npx vsce package |
| 37 | + |
| 38 | + - name: 🏷 Extract version |
| 39 | + id: extract |
| 40 | + run: echo "version=$(jq -r .version package.json)" >> "$GITHUB_OUTPUT" |
| 41 | + |
| 42 | + - name: 📤 Upload .vsix artifact |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: extension-vsix |
| 46 | + path: "*.vsix" |
| 47 | + |
| 48 | + publish_ovsx: |
| 49 | + name: 🚀 Publish to Open VSX |
| 50 | + needs: preparation |
| 51 | + runs-on: ubuntu-latest |
| 52 | + continue-on-error: true # GitHub release will still be created despite Open VSX errors. |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: 🧾 Checkout code |
| 56 | + uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - name: 📥 Download .vsix artifact |
| 59 | + uses: actions/download-artifact@v4 |
| 60 | + with: |
| 61 | + name: extension-vsix |
| 62 | + |
| 63 | + - name: 🧼 Resolve VSIX filename |
| 64 | + id: find_vsix |
| 65 | + run: echo "vsix=$(ls *.vsix)" >> "$GITHUB_OUTPUT" |
| 66 | + |
| 67 | + - name: 📦 Publish extension to Open VSX |
| 68 | + uses: HaaLeo/publish-vscode-extension@v2 |
| 69 | + with: |
| 70 | + pat: ${{ secrets.OPEN_VSX_TOKEN }} |
| 71 | + extensionFile: ${{ steps.find_vsix.outputs.vsix }} |
| 72 | + |
| 73 | + github_release: |
| 74 | + name: 📝 Create GitHub Release |
| 75 | + needs: preparation |
| 76 | + runs-on: ubuntu-latest |
| 77 | + |
| 78 | + steps: |
| 79 | + - name: 🧾 Checkout code |
| 80 | + uses: actions/checkout@v4 |
| 81 | + |
| 82 | + - name: 📥 Download .vsix artifact |
| 83 | + uses: actions/download-artifact@v4 |
| 84 | + with: |
| 85 | + name: extension-vsix |
| 86 | + |
| 87 | + - name: 📤 Upload to GitHub Releases |
| 88 | + uses: softprops/action-gh-release@v2 |
| 89 | + with: |
| 90 | + files: | |
| 91 | + *.vsix |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments