Build VSCode Web #40
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: Build VSCode Web | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Optional VSCode version (x.y.z)" | |
| required: false | |
| type: string | |
| schedule: | |
| - cron: "0 0 * * *" | |
| permissions: | |
| contents: write | |
| id-token: write | |
| pages: write | |
| jobs: | |
| check_update: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_build: ${{ steps.check.outputs.should_build }} | |
| latest_tag: ${{ steps.get_release_tag.outputs.latest_tag }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Resolve target VSCode version | |
| id: get_release_tag | |
| run: | | |
| INPUT_VERSION="${{ github.event.inputs.version }}" | |
| if [ -n "$INPUT_VERSION" ]; then | |
| # Normalize to plain version without leading 'v' | |
| RESOLVED_VERSION="${INPUT_VERSION#v}" | |
| else | |
| RESOLVED_VERSION=$(curl -s https://api.github.com/repos/microsoft/vscode/releases/latest | jq -r .tag_name) | |
| fi | |
| echo "Using version: $RESOLVED_VERSION" | |
| echo "latest_tag=$RESOLVED_VERSION" >> $GITHUB_OUTPUT | |
| - name: Get current package.json version | |
| id: get_current_version | |
| run: | | |
| cd vscode-web-build | |
| CURRENT_VERSION=$(jq -r .version package.json) | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Check and update version | |
| id: check | |
| run: | | |
| cd vscode-web-build | |
| CURRENT_VERSION="${{ steps.get_current_version.outputs.current_version }}" | |
| LATEST_TAG="${{ steps.get_release_tag.outputs.latest_tag }}" | |
| INPUT_VERSION="${{ github.event.inputs.version }}" | |
| if [ -n "$INPUT_VERSION" ]; then | |
| echo "Manual version input provided; forcing build for ${LATEST_TAG}" | |
| echo "should_build=true" >> $GITHUB_OUTPUT | |
| elif [ "$(printf '%s\n' "${CURRENT_VERSION}" "${LATEST_TAG}" | sort -V | head -n1)" = "${CURRENT_VERSION}" ] && [ "${CURRENT_VERSION}" != "${LATEST_TAG}" ]; then | |
| echo "Version is less than latest tag" | |
| echo "should_build=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Version is up to date or greater, skipping build steps" | |
| echo "should_build=false" >> $GITHUB_OUTPUT | |
| fi | |
| build_and_deploy: | |
| runs-on: ubuntu-latest | |
| needs: check_update | |
| if: needs.check_update.outputs.should_build == 'true' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| # git clone --branch x.y.z --single-branch https://github.com/microsoft/vscode.git --depth=1 | |
| - name: Checkout VSCode repository | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: microsoft/vscode | |
| ref: ${{ needs.check_update.outputs.latest_tag }} | |
| path: vscode | |
| - uses: actions/checkout@v5 | |
| with: | |
| repository: microsoft/vscode-loc | |
| path: vscode-loc | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version-file: vscode/.nvmrc | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install build-essential g++ libx11-dev libxkbfile-dev libsecret-1-dev libkrb5-dev python-is-python3 | |
| cd vscode && npm ci | |
| - name: Build VSCode Web | |
| run: | | |
| cd vscode | |
| npm run gulp compile-build-without-mangling # out-build | |
| npm run gulp vscode-web-ci # out-vscode-web .build/web/extensions | |
| cd .. | |
| - name: Copy build | |
| run: | | |
| node nls.mjs | |
| deps_json=$(jq '.dependencies // {}' vscode/remote/web/package.json) | |
| deps_keys=$(jq '.dependencies // {} | keys' vscode/remote/web/package.json) | |
| jq --argjson deps "$deps_json" --argjson bundled "$deps_keys" ' | |
| .dependencies = $deps | |
| | .bundledDependencies = $bundled | |
| ' vscode-web-build/package.json > vscode-web-build/package.json.tmp | |
| cat vscode-web-build/package.json.tmp | |
| mv vscode-web-build/package.json.tmp vscode-web-build/package.json | |
| cp -vR vscode/remote/web/node_modules vscode-web-build/ | |
| cp -vR vscode/out-vscode-web vscode-web-build/out | |
| cp -vR vscode/.build/web/extensions vscode-web-build/ | |
| rsync -vt vscode/resources/server/* vscode-web-build/ | |
| cd vscode-web-build && npm version "${{ needs.check_update.outputs.latest_tag }}" --no-git-tag-version | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: "./vscode-web-build" | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Commit and push version bump | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| # git commit --allow-empty --author="github-actions[bot] <github-actions[bot]@users.noreply.github.com>" | |
| git commit -m "chore: bump version to ${{ needs.check_update.outputs.latest_tag }}" | |
| git push origin HEAD:${GITHUB_REF_NAME} | |
| - name: Package build | |
| run: | | |
| ls -ahlF vscode-web-build | |
| cd vscode-web-build | |
| cat package.json | |
| npm pack | |
| cd .. | |
| - name: Release on GitHub | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ needs.check_update.outputs.latest_tag }} | |
| draft: false | |
| generate_release_notes: false | |
| files: | | |
| vscode-web-build/*.tgz |