瀏覽代碼

fix(snap): squash changes [skip ci]

Baptiste Augrain 1 年之前
父節點
當前提交
3465153c6e
共有 7 個文件被更改,包括 87 次插入100 次删除
  1. 30 19
      .github/workflows/insider-linux.yml
  2. 1 0
      .github/workflows/stable-linux.yml
  3. 1 1
      .gitignore
  4. 0 21
      check_tags.sh
  5. 1 10
      prepare_assets.sh
  6. 30 28
      stores/snapcraft/build.sh
  7. 24 21
      stores/snapcraft/check_version.sh

+ 30 - 19
.github/workflows/insider-linux.yml

@@ -215,15 +215,14 @@ jobs:
       - build
     runs-on: ubuntu-latest
     env:
-      APP_NAME: codium
+      RELEASE_VERSION: ${{ needs.build.outputs.RELEASE_VERSION }}
     strategy:
       fail-fast: false
       matrix:
         platform:
         - amd64
         - arm64
-    # if: needs.build.outputs.SHOULD_DEPLOY == 'yes'
-    if: false
+    if: needs.build.outputs.SHOULD_DEPLOY == 'yes'
 
     steps:
       - uses: actions/checkout@v3
@@ -237,25 +236,37 @@ jobs:
         run: ./stores/snapcraft/check_version.sh
 
       - uses: docker/setup-qemu-action@v3
-        if: env.SHOULD_DEPLOY == 'yes'
+        if: env.SHOULD_BUILD == 'yes'
+
+      - name: Prepare snapcraft.yaml
+        env:
+          ARCHITECTURE: ${{ matrix.platform }}
+        run: ./stores/snapcraft/build.sh
+        if: env.SHOULD_BUILD == 'yes'
+
+      # - uses: diddlesnaps/snapcraft-multiarch-action@v1
+      #   with:
+      #     path: stores/snapcraft/out
+      #     architecture: ${{ matrix.platform }}
+      #   id: build
+      #   if: env.SHOULD_BUILD == 'yes'
 
-      - uses: diddlesnaps/snapcraft-multiarch-action@v1
+      - uses: snapcore/action-build@v1
         with:
-          path: stores/snapcraft/insider
-          architecture: ${{ matrix.platform }}
+          path: stores/snapcraft/out
         id: build
-        if: env.SHOULD_DEPLOY == 'yes'
+        if: env.SHOULD_BUILD == 'yes'
 
-      - uses: diddlesnaps/snapcraft-review-action@v1
-        with:
-          snap: ${{ steps.build.outputs.snap }}
-          isClassic: 'true'
-        if: env.SHOULD_DEPLOY == 'yes'
+      # - uses: diddlesnaps/snapcraft-review-action@v1
+      #   with:
+      #     snap: ${{ steps.build.outputs.snap }}
+      #     isClassic: 'true'
+      #   if: env.SHOULD_BUILD == 'yes'
 
-      - uses: snapcore/action-publish@master
-        env:
-          SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
+      - uses: svenstaro/upload-release-action@v2
         with:
-          snap: ${{ steps.build.outputs.snap }}
-          release: edge
-        if: env.SHOULD_DEPLOY == 'yes'
+          repo_name: ${{ env.ASSETS_REPOSITORY }}
+          repo_token: ${{ secrets.STRONGER_GITHUB_TOKEN }}
+          file: ${{ steps.build.outputs.snap }}
+          tag: ${{ env.RELEASE_VERSION }}
+        if: env.SHOULD_DEPLOY_TO_RELEASE == 'yes'

+ 1 - 0
.github/workflows/stable-linux.yml

@@ -227,6 +227,7 @@ jobs:
     runs-on: ubuntu-latest
     env:
       APP_NAME: codium
+      RELEASE_VERSION: ${{ needs.build.outputs.RELEASE_VERSION }}
     strategy:
       fail-fast: false
       matrix:

+ 1 - 1
.gitignore

@@ -15,4 +15,4 @@ build/windows/msi/releasedir
 build/windows/msi/Files*.wxs
 build/windows/msi/Files*.wixobj
 remote-dependencies.tar
-stores/snapcraft/.build
+stores/snapcraft/build

+ 0 - 21
check_tags.sh

@@ -239,13 +239,6 @@ if [[ "${ASSETS}" != "null" ]]; then
         export SHOULD_BUILD_REH="no"
       fi
 
-      if [[ -z $( contains "arm64.snap" ) ]]; then
-        echo "Building on Linux arm64 because we have no Snap"
-        export SHOULD_BUILD="yes"
-      else
-        export SHOULD_BUILD_SNAP="no"
-      fi
-
       export SHOULD_BUILD_APPIMAGE="no"
 
       if [[ "${SHOULD_BUILD}" != "yes" ]]; then
@@ -283,7 +276,6 @@ if [[ "${ASSETS}" != "null" ]]; then
       fi
 
       export SHOULD_BUILD_APPIMAGE="no"
-      export SHOULD_BUILD_SNAP="no"
 
       if [[ "${SHOULD_BUILD}" != "yes" ]]; then
         echo "Already have all the Linux arm builds"
@@ -294,7 +286,6 @@ if [[ "${ASSETS}" != "null" ]]; then
       SHOULD_BUILD_APPIMAGE="no"
       SHOULD_BUILD_DEB="no"
       SHOULD_BUILD_RPM="no"
-      SHOULD_BUILD_SNAP="no"
       SHOULD_BUILD_TAR="no"
 
       if [[ -z $( contains "${APP_NAME_LC}-reh-linux-ppc64le-${RELEASE_VERSION}.tar.gz" ) ]]; then
@@ -338,13 +329,6 @@ if [[ "${ASSETS}" != "null" ]]; then
         export SHOULD_BUILD_APPIMAGE="no"
       fi
 
-      if [[ -z $( contains "amd64.snap" ) ]]; then
-        echo "Building on Linux x64 because we have no Snap"
-        export SHOULD_BUILD="yes"
-      else
-        export SHOULD_BUILD_SNAP="no"
-      fi
-
       if [[ -z $( contains "${APP_NAME_LC}-reh-linux-x64-${RELEASE_VERSION}.tar.gz" ) ]]; then
         echo "Building on Linux x64 because we have no REH archive"
         export SHOULD_BUILD="yes"
@@ -364,15 +348,11 @@ else
     if [[ "${VSCODE_ARCH}" == "ppc64le" ]]; then
       SHOULD_BUILD_DEB="no"
       SHOULD_BUILD_RPM="no"
-      SHOULD_BUILD_SNAP="no"
       SHOULD_BUILD_TAR="no"
     fi
     if [[ "${VSCODE_ARCH}" != "x64" ]]; then
       export SHOULD_BUILD_APPIMAGE="no"
     fi
-    if [[ "${VSCODE_ARCH}" != "arm64" && "${VSCODE_ARCH}" != "x64" ]]; then
-      export SHOULD_BUILD_SNAP="no"
-    fi
   elif [[ "${OS_NAME}" == "windows" ]]; then
     if [[ "${VSCODE_ARCH}" == "arm64" ]]; then
       export SHOULD_BUILD_REH="no"
@@ -394,7 +374,6 @@ echo "SHOULD_BUILD_MSI=${SHOULD_BUILD_MSI}" >> "${GITHUB_ENV}"
 echo "SHOULD_BUILD_MSI_NOUP=${SHOULD_BUILD_MSI_NOUP}" >> "${GITHUB_ENV}"
 echo "SHOULD_BUILD_REH=${SHOULD_BUILD_REH}" >> "${GITHUB_ENV}"
 echo "SHOULD_BUILD_RPM=${SHOULD_BUILD_RPM}" >> "${GITHUB_ENV}"
-echo "SHOULD_BUILD_SNAP=${SHOULD_BUILD_SNAP}" >> "${GITHUB_ENV}"
 echo "SHOULD_BUILD_TAR=${SHOULD_BUILD_TAR}" >> "${GITHUB_ENV}"
 echo "SHOULD_BUILD_ZIP=${SHOULD_BUILD_ZIP}" >> "${GITHUB_ENV}"
 echo "SHOULD_BUILD_SRC=${SHOULD_BUILD_SRC}" >> "${GITHUB_ENV}"

+ 1 - 10
prepare_assets.sh

@@ -125,7 +125,7 @@ elif [[ "${OS_NAME}" == "windows" ]]; then
 else
   cd vscode || { echo "'vscode' dir not found"; exit 1; }
 
-  if [[ "${SHOULD_BUILD_DEB}" != "no" || "${SHOULD_BUILD_APPIMAGE}" != "no" || "${SHOULD_BUILD_SNAP}" != "no" ]]; then
+  if [[ "${SHOULD_BUILD_DEB}" != "no" || "${SHOULD_BUILD_APPIMAGE}" != "no" ]]; then
     yarn gulp "vscode-linux-${VSCODE_ARCH}-build-deb"
   fi
 
@@ -137,10 +137,6 @@ else
     . ../build/linux/appimage/build.sh
   fi
 
-  if [[ "${SHOULD_BUILD_SNAP}" != "no" ]]; then
-    . ../stores/snapcraft/build.sh
-  fi
-
   cd ..
 
   if [[ "${SHOULD_BUILD_TAR}" != "no" ]]; then
@@ -167,11 +163,6 @@ else
     find assets -name '*.AppImage*' -exec bash -c 'mv $0 ${0/_-_/-}' {} \;
   fi
 
-  if [[ "${SHOULD_BUILD_SNAP}" != "no" ]]; then
-    echo "Moving Snap"
-    mv stores/snapcraft/.build/*.snap assets/
-  fi
-
   VSCODE_PLATFORM="linux"
 fi
 

+ 30 - 28
stores/snapcraft/build.sh

@@ -16,59 +16,61 @@ if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
   ICON_NAME="${ICON_NAME}-insiders"
 fi
 
-rm -rf .build
-mkdir -p .build/snap/gui
-
-DEB_ARCHIVE=$( ls ../../vscode/.build/linux/deb/amd64/deb/*.deb )
-
-if [[ -z "${DEB_ARCHIVE}" ]]; then
-  ARCHITECTURE=$( dpkg --print-architecture )
+rm -rf build
+mkdir -p build/snap/gui
 
+if [[ "${CI_BUILD}" == "no" ]]; then
+  DEB_ARCHIVE=$( ls ../../vscode/build/linux/deb/amd64/deb/*.deb )
+else
   # Get GitHub releases
-  wget --quiet "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases" -O latest.json
+  wget --quiet "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases" -O gh_latest.json
 
-  DEB_URL=$( jq -r 'map(select(.tag_name == "'"${RELEASE_VERSION}"'"))|first.assets[].browser_download_url|select(endswith("'"_${ARCHITECTURE}.deb"'"))' latest.json )
+  DEB_URL=$( jq -r 'map(select(.tag_name == "'"${RELEASE_VERSION}"'"))|first.assets[].browser_download_url|select(endswith("'"_${ARCHITECTURE}.deb"'"))' gh_latest.json )
   DEB_ARCHIVE=$( basename "${DEB_URL}" )
 
   # Downloading .deb
   wget "${DEB_URL}" -O "${DEB_ARCHIVE}"
 
-  rm latest.json
+  rm gh_latest.json
 fi
 
 # Unpacking .deb
-dpkg -x "${DEB_ARCHIVE}" .build/deb
+dpkg -x "${DEB_ARCHIVE}" build/deb
 
-mkdir -p .build/snap/usr/share
-mv ".build/deb/usr/share/${BINARY_NAME}" ".build/snap/usr/share/${BINARY_NAME}"
+mkdir -p build/snap/usr/share
+mv "build/deb/usr/share/${BINARY_NAME}" "build/snap/usr/share/${BINARY_NAME}"
 
 # Prepare snapcraft.yaml
-cp ${VSCODE_QUALITY}/snapcraft.yaml .build/snap/snapcraft.yaml
+cp ${VSCODE_QUALITY}/snapcraft.yaml build/snap/snapcraft.yaml
 
-replace "s|@@SNAP_NAME@@|${BINARY_NAME}|g" .build/snap/snapcraft.yaml
-replace "s|@@SNAP_VERSION@@|${SNAP_VERSION}|g" .build/snap/snapcraft.yaml
+replace "s|@@SNAP_NAME@@|${BINARY_NAME}|g" build/snap/snapcraft.yaml
+replace "s|@@SNAP_VERSION@@|${SNAP_VERSION}|g" build/snap/snapcraft.yaml
 
 # Prepare electron-launch
-cp ${VSCODE_QUALITY}/electron-launch .build/snap/electron-launch
+cp ${VSCODE_QUALITY}/electron-launch build/snap/electron-launch
 
 # Prepare GUI
-cp "../../src/${VSCODE_QUALITY}/resources/linux/code.png" ".build/snap/gui/${BINARY_NAME}.png"
-cp .build/deb/usr/share/applications/*.desktop .build/snap/gui
+cp "../../src/${VSCODE_QUALITY}/resources/linux/code.png" "build/snap/gui/${BINARY_NAME}.png"
+cp build/deb/usr/share/applications/*.desktop build/snap/gui
 
-sed -i "s|Exec=/usr/share/${BINARY_NAME}/${BINARY_NAME}|Exec=${BINARY_NAME} --force-user-env|g" ".build/snap/gui/${BINARY_NAME}.desktop"
-sed -i "s|Exec=/usr/share/${BINARY_NAME}/${BINARY_NAME}|Exec=${BINARY_NAME} --force-user-env|g" ".build/snap/gui/${BINARY_NAME}-url-handler.desktop"
-sed -i "s|Icon=${ICON_NAME}|Icon=\${SNAP}/meta/gui/${BINARY_NAME}.png|g" ".build/snap/gui/${BINARY_NAME}.desktop"
-sed -i "s|Icon=${ICON_NAME}|Icon=\${SNAP}/meta/gui/${BINARY_NAME}.png|g" ".build/snap/gui/${BINARY_NAME}-url-handler.desktop"
+sed -i "s|Exec=/usr/share/${BINARY_NAME}/${BINARY_NAME}|Exec=${BINARY_NAME} --force-user-env|g" "build/snap/gui/${BINARY_NAME}.desktop"
+sed -i "s|Exec=/usr/share/${BINARY_NAME}/${BINARY_NAME}|Exec=${BINARY_NAME} --force-user-env|g" "build/snap/gui/${BINARY_NAME}-url-handler.desktop"
+sed -i "s|Icon=${ICON_NAME}|Icon=\${SNAP}/meta/gui/${BINARY_NAME}.png|g" "build/snap/gui/${BINARY_NAME}.desktop"
+sed -i "s|Icon=${ICON_NAME}|Icon=\${SNAP}/meta/gui/${BINARY_NAME}.png|g" "build/snap/gui/${BINARY_NAME}-url-handler.desktop"
 
 # Clean up
-rm -rf .build/deb
+rm -rf build/deb
 
-cd .build
+cd build
 
-if [[ "${CI_BUILD}" != "no" ]]; then
-  snapcraft
-else
+if [[ "${CI_BUILD}" == "no" ]]; then
   snapcraft --use-lxd --debug
+# else
+#   snapcraft
+
+#   SNAP_ARCHIVE=$( ls *.snap )
+
+#   echo "snap=$( pwd )/${SNAP_ARCHIVE}" >> "$GITHUB_OUTPUT"
 fi
 
 cd "${CALLER_DIR}"

+ 24 - 21
stores/snapcraft/check_version.sh

@@ -2,34 +2,37 @@
 
 set -e
 
-if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
-  SNAP_NAME="${APP_NAME}-insiders"
-else
-  SNAP_NAME="${APP_NAME}"
-fi
-
-sudo snap install --channel stable --classic snapcraft
+export SHOULD_BUILD="no"
+export SHOULD_DEPLOY_TO_RELEASE="no"
+export SHOULD_DEPLOY_TO_STORE="no"
 
-echo "Architecture: ${ARCHITECTURE}"
+if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
+  wget --quiet "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases" -O gh_latest.json
+  SNAP_URL=$( jq -r 'map(select(.tag_name == "'"${RELEASE_VERSION}"'"))|first.assets[].browser_download_url|select(endswith("'"_${ARCHITECTURE}.snap"'"))' gh_latest.json )
 
-SNAP_VERSION=$( snapcraft list-revisions "${SNAP_NAME}" | grep -F "stable*" | grep "${ARCHITECTURE}" | tr -s ' ' | cut -d ' ' -f 4 )
-echo "Snap version: ${SNAP_VERSION}"
+  if [[ -z "${SNAP_URL}" ]]; then
+    export SHOULD_BUILD="yes"
+    export SHOULD_DEPLOY_TO_RELEASE="yes"
+  fi
+else
+  sudo snap install --channel stable --classic snapcraft
 
-wget --quiet "https://api.github.com/repos/${ASSETS_REPOSITORY}/releases" -O gh_latest.json
-GH_VERSION=$( jq -r 'sort_by(.tag_name)|last.tag_name' gh_latest.json )
-echo "GH version: ${GH_VERSION}"
+  echo "Architecture: ${ARCHITECTURE}"
 
-rm -f gh_latest.json
+  SNAP_VERSION=$( snapcraft list-revisions "${SNAP_NAME}" | grep -F "stable*" | grep "${ARCHITECTURE}" | tr -s ' ' | cut -d ' ' -f 4 )
+  echo "Snap version: ${SNAP_VERSION}"
 
-if [[ "${SNAP_VERSION}" == "${GH_VERSION}" ]]; then
-  export SHOULD_DEPLOY="no"
-else
-  export SHOULD_DEPLOY="yes"
+  if [[ "${SNAP_VERSION}" != "${RELEASE_VERSION}" ]]; then
+    export SHOULD_BUILD="yes"
+    export SHOULD_DEPLOY_TO_STORE="yes"
 
-  snap version
-  snap info "${SNAP_NAME}" || true
+    snap version
+    snap info "${SNAP_NAME}" || true
+  fi
 fi
 
 if [[ "${GITHUB_ENV}" ]]; then
-	echo "SHOULD_DEPLOY=${SHOULD_DEPLOY}" >> "${GITHUB_ENV}"
+  echo "SHOULD_BUILD=${SHOULD_BUILD}" >> "${GITHUB_ENV}"
+  echo "SHOULD_DEPLOY_TO_RELEASE=${SHOULD_DEPLOY_TO_RELEASE}" >> "${GITHUB_ENV}"
+	echo "SHOULD_DEPLOY_TO_STORE=${SHOULD_DEPLOY_TO_STORE}" >> "${GITHUB_ENV}"
 fi