|
| 1 | +name: "Release" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - release |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + packages: write |
| 12 | + checks: write |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + uses: ./.github/workflows/test.yml |
| 18 | + |
| 19 | + publish: |
| 20 | + needs: test |
| 21 | + name: Publish Extension |
| 22 | + runs-on: ubuntu-latest |
| 23 | + environment: publish |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Setup Node.js |
| 29 | + uses: actions/setup-node@v4 |
| 30 | + with: |
| 31 | + node-version: "lts/*" |
| 32 | + |
| 33 | + # Cache root dependencies - only reuse if package-lock.json exactly matches |
| 34 | + - name: Cache root dependencies |
| 35 | + uses: actions/cache@v4 |
| 36 | + id: root-cache |
| 37 | + with: |
| 38 | + path: node_modules |
| 39 | + key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} |
| 40 | + |
| 41 | + # Cache webview-ui dependencies - only reuse if package-lock.json exactly matches |
| 42 | + - name: Cache webview-ui dependencies |
| 43 | + uses: actions/cache@v4 |
| 44 | + id: webview-cache |
| 45 | + with: |
| 46 | + path: webview-ui/node_modules |
| 47 | + key: ${{ runner.os }}-npm-webview-${{ hashFiles('webview-ui/package-lock.json') }} |
| 48 | + |
| 49 | + - name: Install root dependencies |
| 50 | + if: steps.root-cache.outputs.cache-hit != 'true' |
| 51 | + run: npm ci --include=optional |
| 52 | + |
| 53 | + - name: Install webview-ui dependencies |
| 54 | + if: steps.webview-cache.outputs.cache-hit != 'true' |
| 55 | + run: cd webview-ui && npm ci --include=optional |
| 56 | + |
| 57 | + - name: Install Publishing Tools |
| 58 | + run: npm install -g @vscode/vsce |
| 59 | + |
| 60 | + - name: Get Version |
| 61 | + id: get_version |
| 62 | + run: | |
| 63 | + VERSION=$(node -p "require('./package.json').version") |
| 64 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 65 | +
|
| 66 | + - name: Create Git Tag |
| 67 | + id: create_tag |
| 68 | + run: | |
| 69 | + VERSION=v${{ steps.get_version.outputs.version }} |
| 70 | + echo "tag=$VERSION" >> $GITHUB_OUTPUT |
| 71 | + echo "Tagging with $VERSION" |
| 72 | + git tag "$VERSION" |
| 73 | + git push origin "$VERSION" |
| 74 | +
|
| 75 | + - name: Package and Publish Extension |
| 76 | + env: |
| 77 | + VSCE_PAT: ${{ secrets.VSCE_PAT }} |
| 78 | + LANGFUSE_API_URL: ${{ secrets.LANGFUSE_API_URL }} |
| 79 | + LANGFUSE_API_KEY: ${{ secrets.LANGFUSE_API_KEY }} |
| 80 | + LANGFUSE_PUBLIC_KEY: ${{ secrets.LANGFUSE_PUBLIC_KEY }} |
| 81 | + POST_HOG_API_KEY: ${{ secrets.POST_HOG_API_KEY }} |
| 82 | + POST_HOG_HOST: ${{ secrets.POST_HOG_API_URL }} |
| 83 | + run: | |
| 84 | + # Required to generate the .vsix |
| 85 | + vsce package --out "hai-build-code-generator-${{ steps.get_version.outputs.version }}.vsix" --allow-package-secrets sendgrid |
| 86 | +
|
| 87 | + if [ "${{ github.event.inputs.release-type }}" = "pre-release" ]; then |
| 88 | + npm run publish:marketplace:prerelease |
| 89 | + echo "Successfully published pre-release version ${{ steps.get_version.outputs.version }} to VS Code Marketplace" |
| 90 | + else |
| 91 | + npm run publish:marketplace |
| 92 | + echo "Successfully published release version ${{ steps.get_version.outputs.version }} to VS Code Marketplace" |
| 93 | + fi |
| 94 | +
|
| 95 | + # - name: Get Changelog Entry |
| 96 | + # id: changelog |
| 97 | + # uses: mindsers/changelog-reader-action@v2 |
| 98 | + # with: |
| 99 | + # # This expects a standard Keep a Changelog format |
| 100 | + # # "latest" means it will read whichever is the most recent version |
| 101 | + # # set in "## [1.2.3] - 2025-01-28" style |
| 102 | + # version: latest |
| 103 | + |
| 104 | + - name: Create GitHub Release |
| 105 | + uses: softprops/action-gh-release@v1 |
| 106 | + with: |
| 107 | + tag_name: ${{ steps.create_tag.outputs.tag }} |
| 108 | + files: "*.vsix" |
| 109 | + # body: ${{ steps.changelog.outputs.content }} |
| 110 | + generate_release_notes: true |
| 111 | + prerelease: ${{ github.event.inputs.release-type == 'pre-release' }} |
| 112 | + env: |
| 113 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments