Build VSCode Web #116
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 code-oss | |
| CURRENT_VERSION=$(jq -r .version package.json) | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Check and update version | |
| id: check | |
| run: | | |
| cd code-oss | |
| 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 | |
| - 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 | |
| ' code-oss/package.json > code-oss/package.json.tmp | |
| cat code-oss/package.json.tmp | |
| mv code-oss/package.json.tmp code-oss/package.json | |
| cp -vR vscode/remote/web/node_modules code-oss/ | |
| cp -vR vscode/out-vscode-web code-oss/out | |
| cp -vR vscode/.build/web/extensions code-oss/ | |
| rsync -vt vscode/resources/server/* code-oss/ | |
| cd code-oss && 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: "./code-oss" | |
| # - name: Deploy to GitHub Pages | |
| # id: deployment | |
| # uses: actions/deploy-pages@v4 | |
| - name: Commit and push version bump | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config --global init.defaultBranch main | |
| git config --global user.name "github-actions[bot]" | |
| git config --global 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} | |
| origin="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git" | |
| tmp_dir=$(mktemp -d -t code-oss-XXX) | |
| cp -R code-oss/* $tmp_dir | |
| cd $tmp_dir | |
| git init | |
| git branch -M gh-pages | |
| git remote add origin $origin | |
| git add -A | |
| git commit --allow-empty-message -m "${{ needs.check_update.outputs.latest_tag }}" | |
| git push -f origin gh-pages | |
| - name: Package build | |
| run: | | |
| ls -ahlF code-oss | |
| cp README.md code-oss/ | |
| cd code-oss | |
| cat package.json | |
| npm pack | |
| - name: Publishing on NPM | |
| uses: JS-DevTools/npm-publish@v4 | |
| with: | |
| token: ${{ secrets.NPM_TOKEN }} | |
| package: ./code-oss | |
| access: public | |
| provenance: true | |
| - 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: | | |
| code-oss/code-oss-*.tgz |