瀏覽代碼

Merge pull request #666 from daiyam/fix-build

Peter Squicciarini 4 年之前
父節點
當前提交
88f37a102a

+ 26 - 4
.github/workflows/linux.yml

@@ -42,6 +42,9 @@ jobs:
       - name: Install Yarn
         run: npm install -g yarn
 
+      - name: Check PR or cron
+        run: ./check_cron_or_pr.sh
+
       - name: Clone VSCode repo
         run: ./get_repo.sh
 
@@ -49,6 +52,25 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: ./check_tags.sh
+        if: env.SHOULD_DEPLOY == 'yes'
+
+      - name: Compute cache key
+        id: yarnCacheKey
+        run: echo "::set-output name=value::$(node build/azure-pipelines/computeYarnCacheKey.js)"
+        if: env.SHOULD_BUILD == 'yes'
+
+      - name: Get yarn cache directory path
+        id: yarnCacheDirPath
+        run: echo "::set-output name=dir::$(yarn cache dir)"
+        if: env.SHOULD_BUILD == 'yes'
+
+      - name: Cache yarn directory
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.yarnCacheDirPath.outputs.dir }}
+          key: linux-${{ matrix.npm_arch }}-yarnCacheDir-${{ steps.yarnCacheKey.outputs.value }}
+          restore-keys: linux-${{ matrix.npm_arch }}-yarnCacheDir-
+        if: env.SHOULD_BUILD == 'yes'
 
       - name: Build
         env:
@@ -61,15 +83,15 @@ jobs:
         run: |
           cd VSCode-linux-${VSCODE_ARCH}
           tar czf ../VSCodium-linux-${VSCODE_ARCH}-${LATEST_MS_TAG}.tar.gz .
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
 
       - name: Generate shasums
         run: ./sum.sh
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
       
       - name: Release
         uses: softprops/action-gh-release@v1
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         with:
           tag_name: ${{ env.LATEST_MS_TAG }}
           files: |
@@ -84,7 +106,7 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Update versions repo
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         run: ./update_version.sh
         env:
           GITHUB_TOKEN: ${{ secrets.STRONGER_GITHUB_TOKEN }}

+ 30 - 7
.github/workflows/macos.yml

@@ -21,6 +21,10 @@ jobs:
         with:
           node-version: 12.14.1
           
+      - name: Check PR or cron
+        run: |
+          . check_cron_or_pr.sh
+
       - name: Clone VSCode repo
         run: |
           . get_repo.sh
@@ -30,7 +34,26 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: |
           . check_tags.sh
-          
+        if: env.SHOULD_DEPLOY == 'yes'
+
+      - name: Compute cache key
+        id: yarnCacheKey
+        run: echo "::set-output name=value::$(node build/azure-pipelines/computeYarnCacheKey.js)"
+        if: env.SHOULD_BUILD == 'yes'
+
+      - name: Get yarn cache directory path
+        id: yarnCacheDirPath
+        run: echo "::set-output name=dir::$(yarn cache dir)"
+        if: env.SHOULD_BUILD == 'yes'
+
+      - name: Cache yarn directory
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.yarnCacheDirPath.outputs.dir }}
+          key: ${{ env.OS_NAME }}-${{ env.VSCODE_ARCH }}-yarnCacheDir-${{ steps.yarnCacheKey.outputs.value }}
+          restore-keys: ${{ env.OS_NAME }}-${{ env.VSCODE_ARCH }}-yarnCacheDir-
+        if: env.SHOULD_BUILD == 'yes'
+
       - name: Build
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -42,7 +65,7 @@ jobs:
           CERTIFICATE_OSX_P12: ${{ secrets.CERTIFICATE_OSX_P12 }}
           CERTIFICATE_OSX_PASSWORD: ${{ secrets.CERTIFICATE_OSX_PASSWORD }}
           CERTIFICATE_OSX_ID: ${{ secrets.CERTIFICATE_OSX_ID }}
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         run: |
           if [ -d "VSCode-darwin-${VSCODE_ARCH}" ]; then # just in case the build failed
             cd "VSCode-darwin-${VSCODE_ARCH}"
@@ -61,7 +84,7 @@ jobs:
         run: |
           cd "VSCode-darwin-${VSCODE_ARCH}"
           zip -r -X -y ../VSCodium-darwin-${VSCODE_ARCH}-${LATEST_MS_TAG}.zip ./*.app
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
 
       - name: DMG the release
         run: |
@@ -69,15 +92,15 @@ jobs:
           npx create-dmg VSCodium.app ..
           mv "../VSCodium ${LATEST_MS_TAG}.dmg" "../VSCodium.${VSCODE_ARCH}.${LATEST_MS_TAG}.dmg"
           popd
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
 
       - name: Generate shasums
         run: ./sum.sh
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
       
       - name: Release
         uses: softprops/action-gh-release@v1
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         with:
           tag_name: ${{ env.LATEST_MS_TAG }}
           files: |
@@ -88,7 +111,7 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Update versions repo
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         run: ./update_version.sh
         env:
           GITHUB_TOKEN: ${{ secrets.STRONGER_GITHUB_TOKEN }}

+ 27 - 4
.github/workflows/windows.yml

@@ -34,6 +34,10 @@ jobs:
         with:
           python-version: '2.x'
 
+      - name: Check PR or cron
+        run: ./check_cron_or_pr.sh
+        shell: bash
+
       - name: Clone VSCode repo
         run: ./get_repo.sh
         shell: bash
@@ -43,6 +47,25 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
         run: ./check_tags.sh
         shell: bash
+        if: env.SHOULD_DEPLOY == 'yes'
+
+      - name: Compute cache key
+        id: yarnCacheKey
+        run: echo "::set-output name=value::$(node build/azure-pipelines/computeYarnCacheKey.js)"
+        if: env.SHOULD_BUILD == 'yes'
+
+      - name: Get yarn cache directory path
+        id: yarnCacheDirPath
+        run: echo "::set-output name=dir::$(yarn cache dir)"
+        if: env.SHOULD_BUILD == 'yes'
+
+      - name: Cache yarn directory
+        uses: actions/cache@v2
+        with:
+          path: ${{ steps.yarnCacheDirPath.outputs.dir }}
+          key: ${{ env.OS_NAME }}-${{ env.VSCODE_ARCH }}-yarnCacheDir-${{ steps.yarnCacheKey.outputs.value }}
+          restore-keys: ${{ env.OS_NAME }}-${{ env.VSCODE_ARCH }}-yarnCacheDir-
+        if: env.SHOULD_BUILD == 'yes'
 
       - name: Build
         env:
@@ -59,16 +82,16 @@ jobs:
           mv vscode\\.build\\win32-${VSCODE_ARCH}\\user-setup\\VSCodeSetup.exe VSCodiumUserSetup-${VSCODE_ARCH}-${LATEST_MS_TAG}.exe
           mv vscode\\.build\\win32-${VSCODE_ARCH}\\archive\\VSCode-win32-${VSCODE_ARCH}.zip VSCodium-win32-${VSCODE_ARCH}-${LATEST_MS_TAG}.zip
         shell: bash
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
 
       - name: Generate shasums
         run: ./sum.sh
         shell: bash
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
       
       - name: Release
         uses: softprops/action-gh-release@v1
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         with:
           tag_name: ${{ env.LATEST_MS_TAG }}
           files: |
@@ -80,7 +103,7 @@ jobs:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Update versions repo
-        if: env.SHOULD_BUILD == 'yes'
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         run: ./update_version.sh
         shell: bash
         env:

+ 24 - 0
build/azure-pipelines/computeYarnCacheKey.js

@@ -0,0 +1,24 @@
+const fs = require("fs");
+const crypto = require("crypto");
+const path = require("path");
+const { dirs } = require('../../vscode/build/npm/dirs');
+
+const ROOT = path.join(__dirname, '../../vscode');
+
+const shasum = crypto.createHash('sha1');
+
+shasum.update(fs.readFileSync(path.join(ROOT, '.yarnrc')));
+shasum.update(fs.readFileSync(path.join(ROOT, 'remote/.yarnrc')));
+
+// Add `yarn.lock` files
+for (let dir of dirs) {
+    const yarnLockPath = path.join(ROOT, dir, 'yarn.lock');
+    shasum.update(fs.readFileSync(yarnLockPath));
+}
+
+// Add any other command line arguments
+for (let i = 2; i < process.argv.length; i++) {
+    shasum.update(process.argv[i]);
+}
+
+process.stdout.write(shasum.digest('hex'));

+ 8 - 0
build/build_linux.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+rm -rf VSCode*
+rm -rf vscode
+
+./get_repo.sh
+
+SHOULD_BUILD=yes CI_BUILD=no OS_NAME=linux VSCODE_ARCH=x64 ./build.sh

+ 8 - 0
build/build_macos.sh

@@ -0,0 +1,8 @@
+#!/bin/bash
+
+rm -rf VSCode*
+rm -rf vscode
+
+. get_repo.sh
+
+SHOULD_BUILD=yes CI_BUILD=no OS_NAME=osx VSCODE_ARCH=x64 . build.sh

+ 15 - 0
build/build_windows.ps1

@@ -0,0 +1,15 @@
+# powershell -ExecutionPolicy ByPass -File build_windows.ps1
+
+$env:Path += ";C:\Program Files\Git\bin"
+
+Remove-Item -Recurse -Force VSCode*
+Remove-Item -Recurse -Force vscode
+
+bash ./get_repo.sh
+
+$Env:SHOULD_BUILD = 'yes'
+$Env:CI_BUILD = 'no'
+$Env:OS_NAME = 'windows'
+$Env:VSCODE_ARCH = 'x64'
+
+bash ./build.sh

+ 19 - 0
check_cron_or_pr.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+set -e
+
+if [[ $github.event.number ]]; then
+	echo "It's a PR"
+	
+	export SHOULD_BUILD="yes"
+	export SHOULD_DEPLOY="no"
+else
+	echo "It's a cron"
+	
+	export SHOULD_DEPLOY="yes"
+fi
+
+if [[ $GITHUB_ENV ]]; then
+	echo "SHOULD_BUILD=$SHOULD_BUILD" >> $GITHUB_ENV
+	echo "SHOULD_DEPLOY=$SHOULD_DEPLOY" >> $GITHUB_ENV
+fi

+ 4 - 3
get_repo.sh

@@ -9,6 +9,7 @@ echo "Got the latest MS tag: ${LATEST_MS_TAG}"
 git clone https://github.com/Microsoft/vscode.git --branch $LATEST_MS_TAG --depth 1
 
 # for GH actions
-echo "LATEST_MS_COMMIT=$LATEST_MS_COMMIT" >> $GITHUB_ENV
-echo "LATEST_MS_TAG=$LATEST_MS_TAG" >> $GITHUB_ENV
-
+if [[ $GITHUB_ENV ]]; then
+	echo "LATEST_MS_COMMIT=$LATEST_MS_COMMIT" >> $GITHUB_ENV
+	echo "LATEST_MS_TAG=$LATEST_MS_TAG" >> $GITHUB_ENV
+fi

+ 1 - 1
patches/fix-rpm-spec.patch

@@ -13,4 +13,4 @@
  /usr/share/bash-completion/completions/@@NAME@@
  /usr/share/zsh/site-functions/_@@NAME@@
 +
-++%config(noreplace) /usr/share/@@NAME@@/resources/app/product.json
++%config(noreplace) /usr/share/@@NAME@@/resources/app/product.json

+ 1 - 5
patches/update-cache-path.patch

@@ -1,11 +1,7 @@
 --- vscode/src/vs/platform/update/electron-main/updateService.win32.ts	2021-02-05 11:59:17.564060663 -0600
 +++ src/src/vs/platform/update/electron-main/updateService.win32.ts	2021-02-05 11:59:39.780745778 -0600
-@@ -55,7 +55,7 @@
- 
+@@ -56,3 +56,3 @@
  	@memoize
  	get cachePath(): Promise<string> {
 -		const result = path.join(tmpdir(), `vscode-update-${product.target}-${process.arch}`);
 +		const result = path.join(tmpdir(), `vscodium-update-${product.target}-${process.arch}`);
- 		return pfs.mkdirp(result).then(() => result);
- 	}
-