feat: publish snap (#942)

This commit is contained in:
Baptiste Augrain 2021-12-17 23:21:31 +01:00 committed by GitHub
parent 1ef601a79b
commit 33a6670cad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 198 additions and 9 deletions

View file

@ -9,7 +9,7 @@ on:
branches: [ master ]
jobs:
linux:
release:
runs-on: ubuntu-latest
container:
image: ${{ matrix.image }}
@ -93,9 +93,30 @@ jobs:
if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
- name: Update versions repo
if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes'
run: ./update_version.sh
env:
GITHUB_TOKEN: ${{ secrets.STRONGER_GITHUB_TOKEN }}
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'

View file

@ -65,7 +65,7 @@ scoop install vscodium
```
#### <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):
```bash
snap install codium --classic

View file

@ -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
stores/snapcraft/deploy.sh Executable file
View file

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

View file

@ -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 "$@"

View file

@ -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