Selaa lähdekoodia

feat: publish snap (#942)

Baptiste Augrain 3 vuotta sitten
vanhempi
sitoutus
33a6670cad

+ 23 - 2
.github/workflows/linux.yml

@@ -9,7 +9,7 @@ on:
     branches: [ master ]
     branches: [ master ]
 
 
 jobs:
 jobs:
-  linux:
+  release:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
     container:
     container:
       image: ${{ matrix.image }}
       image: ${{ matrix.image }}
@@ -93,9 +93,30 @@ jobs:
         if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
 
 
       - name: Update versions repo
       - name: Update versions repo
-        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
         run: ./update_version.sh
         run: ./update_version.sh
         env:
         env:
           GITHUB_TOKEN: ${{ secrets.STRONGER_GITHUB_TOKEN }}
           GITHUB_TOKEN: ${{ secrets.STRONGER_GITHUB_TOKEN }}
           GITHUB_USERNAME: ${{ github.repository_owner }}
           GITHUB_USERNAME: ${{ github.repository_owner }}
+        if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
+
+  snap:
+    needs: release
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v2
 
 
+      - name: Check deploy
+        run: ./stores/snapcraft/check_deploy.sh
+
+      - name: Build snap
+        uses: snapcore/action-build@v1
+        with:
+          path: stores/snapcraft
+        if: env.SHOULD_DEPLOY == 'yes'
+
+      - name: Publish snap
+        run: ./stores/snapcraft/deploy.sh
+        env:
+          SNAP_STORE_LOGIN: ${{ secrets.SNAP_STORE_LOGIN }}
+        if: env.SHOULD_DEPLOY == 'yes'

+ 7 - 7
README.md

@@ -7,7 +7,7 @@
 
 
 <div id="badges" align="center">
 <div id="badges" align="center">
 
 
-  [![current release](https://img.shields.io/github/release/vscodium/vscodium.svg)](https://github.com/vscodium/vscodium/releases)
+[![current release](https://img.shields.io/github/release/vscodium/vscodium.svg)](https://github.com/vscodium/vscodium/releases)
 [![windows_build_status](https://dev.azure.com/vscodium/VSCodium/_apis/build/status/VSCodium.vscodium?branchName=master)](https://dev.azure.com/vscodium/VSCodium/_build?definitionId=1)
 [![windows_build_status](https://dev.azure.com/vscodium/VSCodium/_apis/build/status/VSCodium.vscodium?branchName=master)](https://dev.azure.com/vscodium/VSCodium/_build?definitionId=1)
 [![license](https://img.shields.io/github/license/VSCodium/vscodium.svg)](https://github.com/VSCodium/vscodium/blob/master/LICENSE)
 [![license](https://img.shields.io/github/license/VSCodium/vscodium.svg)](https://github.com/VSCodium/vscodium/blob/master/LICENSE)
 [![Gitter](https://img.shields.io/gitter/room/vscodium/vscodium.svg)](https://gitter.im/VSCodium/Lobby)
 [![Gitter](https://img.shields.io/gitter/room/vscodium/vscodium.svg)](https://gitter.im/VSCodium/Lobby)
@@ -65,14 +65,14 @@ scoop install vscodium
 ```
 ```
 
 
 #### <a id="install-with-snap"></a>Install with snap (GNU/Linux)
 #### <a id="install-with-snap"></a>Install with snap (GNU/Linux)
-VSCodium is available in the [Snap Store](https://snapcraft.io/) as [Codium](https://snapcraft.io/codium), published by the [Snapcrafters](https://github.com/snapcrafters/codium) community.
+VSCodium is available in the [Snap Store](https://snapcraft.io/) as [Codium](https://snapcraft.io/codium), thanks to the help of the [Snapcrafters](https://github.com/snapcrafters/codium) community.
 If your GNU/Linux distribution has support for [snaps](https://snapcraft.io/docs/installing-snapd):
 If your GNU/Linux distribution has support for [snaps](https://snapcraft.io/docs/installing-snapd):
 ```bash
 ```bash
 snap install codium --classic
 snap install codium --classic
 ```
 ```
 
 
 #### <a id="install-with-package-manager"></a>Install with Package Manager (GNU/Linux)
 #### <a id="install-with-package-manager"></a>Install with Package Manager (GNU/Linux)
-You can always install using the downloads (deb, rpm, tar) on the [releases page](https://github.com/VSCodium/vscodium/releases), but you can also install using your favorite package manager and get automatic updates. [@paulcarroty](https://github.com/paulcarroty) has set up a repository with instructions [here](https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo). Any issues installing VSCodium using your package manager should be directed to that repository's issue tracker. 
+You can always install using the downloads (deb, rpm, tar) on the [releases page](https://github.com/VSCodium/vscodium/releases), but you can also install using your favorite package manager and get automatic updates. [@paulcarroty](https://github.com/paulcarroty) has set up a repository with instructions [here](https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo). Any issues installing VSCodium using your package manager should be directed to that repository's issue tracker.
 
 
 #### <a id="install-on-arch-linux"></a>Install on Arch Linux
 #### <a id="install-on-arch-linux"></a>Install on Arch Linux
 VSCodium is available in [AUR](https://wiki.archlinux.org/index.php/Arch_User_Repository) as package [vscodium-bin](https://aur.archlinux.org/packages/vscodium-bin/), maintained by [@binex-dsk](https://github.com/binex-dsk). An alternative package [vscodium-git](https://aur.archlinux.org/packages/vscodium-git/), maintained by [@cedricroijakkers](https://github.com/cedricroijakkers), is also available should you wish to compile from source yourself.
 VSCodium is available in [AUR](https://wiki.archlinux.org/index.php/Arch_User_Repository) as package [vscodium-bin](https://aur.archlinux.org/packages/vscodium-bin/), maintained by [@binex-dsk](https://github.com/binex-dsk). An alternative package [vscodium-git](https://aur.archlinux.org/packages/vscodium-git/), maintained by [@cedricroijakkers](https://github.com/cedricroijakkers), is also available should you wish to compile from source yourself.
@@ -88,10 +88,10 @@ flatpak run com.vscodium.codium
 ## <a id="why"></a>Why Does This Exist
 ## <a id="why"></a>Why Does This Exist
 This repository contains build files to generate free release binaries of Microsoft's VS Code. When we speak of "free software", we're talking about freedom, not price.
 This repository contains build files to generate free release binaries of Microsoft's VS Code. When we speak of "free software", we're talking about freedom, not price.
 
 
-Microsoft's releases of Visual Studio Code are licensed under [this not-FLOSS license](https://code.visualstudio.com/license) and contain telemetry/tracking. According to [this comment](https://github.com/Microsoft/vscode/issues/60#issuecomment-161792005) from a Visual Studio Code maintainer: 
+Microsoft's releases of Visual Studio Code are licensed under [this not-FLOSS license](https://code.visualstudio.com/license) and contain telemetry/tracking. According to [this comment](https://github.com/Microsoft/vscode/issues/60#issuecomment-161792005) from a Visual Studio Code maintainer:
 
 
 > When we [Microsoft] build Visual Studio Code, we do exactly this. We clone the vscode repository, we lay down a customized product.json that has Microsoft specific functionality (telemetry, gallery, logo, etc.), and then produce a build that we release under our license.
 > When we [Microsoft] build Visual Studio Code, we do exactly this. We clone the vscode repository, we lay down a customized product.json that has Microsoft specific functionality (telemetry, gallery, logo, etc.), and then produce a build that we release under our license.
-> 
+>
 > When you clone and build from the vscode repo, none of these endpoints are configured in the default product.json. Therefore, you generate a "clean" build, without the Microsoft customizations, which is by default licensed under the MIT license
 > When you clone and build from the vscode repo, none of these endpoints are configured in the default product.json. Therefore, you generate a "clean" build, without the Microsoft customizations, which is by default licensed under the MIT license
 
 
 This repo exists so that you don't have to download+build from source. The build scripts in this repo clone Microsoft's vscode repo, run the build commands, and upload the resulting binaries to [GitHub releases](https://github.com/VSCodium/vscodium/releases). __These binaries are licensed under the MIT license. Telemetry is disabled.__
 This repo exists so that you don't have to download+build from source. The build scripts in this repo clone Microsoft's vscode repo, run the build commands, and upload the resulting binaries to [GitHub releases](https://github.com/VSCodium/vscodium/releases). __These binaries are licensed under the MIT license. Telemetry is disabled.__
@@ -120,7 +120,7 @@ Please note that some Visual Studio Code extensions have licenses that restrict
 ### How are the VSCodium binaries built?
 ### How are the VSCodium binaries built?
 If you would like to see the commands we run to build `vscode` into VSCodium binaries, have a look at the workflow files in `.github/workflows` for Windows, GNU/Linux and macOS. These build files call all the other scripts in the repo. If you find something that doesn't make sense, feel free to ask about it [on Gitter](https://gitter.im/VSCodium/Lobby).
 If you would like to see the commands we run to build `vscode` into VSCodium binaries, have a look at the workflow files in `.github/workflows` for Windows, GNU/Linux and macOS. These build files call all the other scripts in the repo. If you find something that doesn't make sense, feel free to ask about it [on Gitter](https://gitter.im/VSCodium/Lobby).
 
 
-The builds are run every day, but exit early if there isn't a new release from Microsoft. 
+The builds are run every day, but exit early if there isn't a new release from Microsoft.
 
 
 ## <a id="supported-platforms"></a>Supported Platforms
 ## <a id="supported-platforms"></a>Supported Platforms
 The minimal version is limitted by the core component Electron, you may want to check its [supported platform list](https://www.electronjs.org/docs/tutorial/support#supported-platforms).
 The minimal version is limitted by the core component Electron, you may want to check its [supported platform list](https://www.electronjs.org/docs/tutorial/support#supported-platforms).
@@ -133,7 +133,7 @@ The minimal version is limitted by the core component Electron, you may want to
 - [x] Windows 7 or newer x64
 - [x] Windows 7 or newer x64
 - [x] Windows 7 or newer x86
 - [x] Windows 7 or newer x86
 - [x] Windows 10 arm64
 - [x] Windows 10 arm64
-  
+
 ## <a id="donate"></a>Donate
 ## <a id="donate"></a>Donate
 If you would like to support the development of VSCodium, feel free to send BTC to `3PgjE95yzBDTrSPxPiqoxSgZFuKPPAix1N`.
 If you would like to support the development of VSCodium, feel free to send BTC to `3PgjE95yzBDTrSPxPiqoxSgZFuKPPAix1N`.
 
 

+ 35 - 0
stores/snapcraft/check_deploy.sh

@@ -0,0 +1,35 @@
+#!/bin/bash
+
+set -e
+
+if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
+	echo "It's a PR"
+
+	export SHOULD_DEPLOY="no"
+elif [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
+	echo "It's a Push"
+
+	export SHOULD_DEPLOY="no"
+else
+	echo "It's a cron"
+
+  sudo apt install curl jq
+
+  sudo curl -sS --unix-socket /run/snapd.socket http://localhost/v2/find\?q\=codium > snap_latest.json
+  SNAP_VERSION=$(jq -r '.result|map(select(.id == "lIZWXTqmo6LFSts5Cgk2VPlNwtysZAeH"))|.version' snap_latest.json)
+  echo "Snap version: ${SNAP_VERSION}"
+
+  wget --quiet https://api.github.com/repos/VSCodium/vscodium/releases -O gh_latest.json
+  GH_VERSION=$(jq -r 'sort_by(.tag_name)|last.tag_name' gh_latest.json)
+  echo "GH version: ${GH_VERSION}"
+
+  if [[ "${SNAP_VERSION}" == "${GH_VERSION}" ]]; then
+    export SHOULD_DEPLOY="no"
+  else
+	  export SHOULD_DEPLOY="yes"
+  fi
+fi
+
+if [[ $GITHUB_ENV ]]; then
+	echo "SHOULD_DEPLOY=$SHOULD_DEPLOY" >> $GITHUB_ENV
+fi

+ 9 - 0
stores/snapcraft/deploy.sh

@@ -0,0 +1,9 @@
+#!/bin/bash
+
+set -e
+
+echo "$SNAP_STORE_LOGIN" | snapcraft login --with -
+
+snapcraft upload --release=stable *.snap
+
+snapcraft logout

+ 34 - 0
stores/snapcraft/snap/local/bin/electron-launch

@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+
+# On Fedora $SNAP is under /var and there is some magic to map it to /snap.
+# We need to handle that case and reset $SNAP
+SNAP=$(echo "$SNAP" | sed -e "s|/var/lib/snapd||g")
+
+if [ "$SNAP_ARCH" == "amd64" ]; then
+  ARCH="x86_64-linux-gnu"
+elif [ "$SNAP_ARCH" == "armhf" ]; then
+  ARCH="arm-linux-gnueabihf"
+elif [ "$SNAP_ARCH" == "arm64" ]; then
+  ARCH="aarch64-linux-gnu"
+else
+  ARCH="$SNAP_ARCH-linux-gnu"
+fi
+
+GDK_CACHE_DIR="$SNAP_USER_COMMON/.cache"
+if [[ -d "$SNAP_USER_DATA/.cache" && ! -e "$GDK_CACHE_DIR" ]]; then
+  # the .cache directory used to be stored under $SNAP_USER_DATA, migrate it
+  mv "$SNAP_USER_DATA/.cache" "$SNAP_USER_COMMON/"
+fi
+[ ! -d "$GDK_CACHE_DIR" ] && mkdir -p "$GDK_CACHE_DIR"
+
+# Gdk-pixbuf loaders
+export GDK_PIXBUF_MODULE_FILE="$GDK_CACHE_DIR/gdk-pixbuf-loaders.cache"
+export GDK_PIXBUF_MODULEDIR="$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/2.10.0/loaders"
+if [ -f "$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders" ]; then
+  "$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders" > "$GDK_PIXBUF_MODULE_FILE"
+fi
+
+# Create $XDG_RUNTIME_DIR if not exists (to be removed when https://pad.lv/1656340 is fixed)
+[ -n "$XDG_RUNTIME_DIR" ] && mkdir -p "$XDG_RUNTIME_DIR" -m 700
+
+exec "$@"

+ 90 - 0
stores/snapcraft/snap/snapcraft.yaml

@@ -0,0 +1,90 @@
+name: codium
+adopt-info: codium
+summary: Code editing. Redefined.
+description: |
+  Binary releases of Code without branding/telemetry/licensing
+
+base: core18
+grade: stable
+confinement: classic
+compression: lzo
+architectures:
+  - build-on: amd64
+  - build-on: arm64
+
+parts:
+  codium:
+    plugin: nil
+    override-build: |
+      set -eu
+      ARCHITECTURE=$(dpkg --print-architecture)
+      # Get GitHub releases
+      wget --quiet https://api.github.com/repos/VSCodium/vscodium/releases -O latest.json
+      VERSION=$(jq -r 'sort_by(.tag_name)|last.tag_name' latest.json)
+      DEB_URL=$(jq -r 'map(select(.tag_name == "'"$VERSION"'"))|first.assets[].browser_download_url|select(endswith("'"_$ARCHITECTURE.deb"'"))' latest.json)
+      DEB=$(basename "${DEB_URL}")
+      # Downloading .deb"
+      wget "${DEB_URL}" -O "${SNAPCRAFT_PART_INSTALL}/${DEB}"
+      # Unpacking .deb"
+      dpkg -x "${SNAPCRAFT_PART_INSTALL}/${DEB}" ${SNAPCRAFT_PART_INSTALL}
+      rm -f latest.json
+      rm -f "${SNAPCRAFT_PART_INSTALL}/${DEB}"
+      # Correct path to icon.
+      sed -i 's|Icon=codium|Icon=${SNAP}/usr/share/pixmaps/codium.png|g' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium.desktop
+      sed -i 's|Exec=/usr/share/codium/codium|Exec=codium|g' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium.desktop
+      sed -i 's|Icon=codium|Icon=/usr/share/pixmaps/codium.png|g' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/codium-url-handler.desktop
+      # Set version
+      echo $VERSION > $SNAPCRAFT_STAGE/version
+      snapcraftctl set-version "$VERSION"
+    build-packages:
+      - dpkg
+      - jq
+      - sed
+      - wget
+    stage-packages:
+      - ibus-gtk3
+      - fcitx-frontend-gtk3
+      - gvfs-libs
+      - libasound2
+      - libgconf-2-4
+      - libglib2.0-bin
+      - libgnome-keyring0
+      - libgbm1
+      - libgtk-3-0
+      - libxkbfile1
+      - libnotify4
+      - libnspr4
+      - libnss3
+      - libpcre3
+      - libpulse0
+      - libsecret-1-0
+      - libxshmfence1
+      - libxss1
+      - libxtst6
+      - zlib1g
+    prime:
+      - -usr/share/doc
+      - -usr/share/fonts
+      - -usr/share/icons
+      - -usr/share/lintian
+      - -usr/share/man
+
+  electron-launch:
+    after:
+      - codium
+    plugin: dump
+    source: snap/local
+
+apps:
+  codium:
+    command: electron-launch $SNAP/usr/share/codium/bin/codium --no-sandbox
+    common-id: codium.desktop
+    environment:
+      DISABLE_WAYLAND: 1
+      GSETTINGS_SCHEMA_DIR: $SNAP/usr/share/glib-2.0/schemas
+
+  url-handler:
+    command: electron-launch $SNAP/usr/share/codium/bin/codium --open-url --no-sandbox
+    environment:
+      DISABLE_WAYLAND: 1
+      GSETTINGS_SCHEMA_DIR: $SNAP/usr/share/glib-2.0/schemas