fix(snap): squash changes [skip ci]

This commit is contained in:
Baptiste Augrain
2024-02-08 16:10:05 +01:00
parent 96f53366b7
commit 3465153c6e
7 changed files with 90 additions and 103 deletions

View File

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

View File

@@ -2,34 +2,37 @@
set -e
export SHOULD_BUILD="no"
export SHOULD_DEPLOY_TO_RELEASE="no"
export SHOULD_DEPLOY_TO_STORE="no"
if [[ "${VSCODE_QUALITY}" == "insider" ]]; then
SNAP_NAME="${APP_NAME}-insiders"
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 )
if [[ -z "${SNAP_URL}" ]]; then
export SHOULD_BUILD="yes"
export SHOULD_DEPLOY_TO_RELEASE="yes"
fi
else
SNAP_NAME="${APP_NAME}"
fi
sudo snap install --channel stable --classic snapcraft
sudo snap install --channel stable --classic snapcraft
echo "Architecture: ${ARCHITECTURE}"
echo "Architecture: ${ARCHITECTURE}"
SNAP_VERSION=$( snapcraft list-revisions "${SNAP_NAME}" | grep -F "stable*" | grep "${ARCHITECTURE}" | tr -s ' ' | cut -d ' ' -f 4 )
echo "Snap version: ${SNAP_VERSION}"
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}" != "${RELEASE_VERSION}" ]]; then
export SHOULD_BUILD="yes"
export SHOULD_DEPLOY_TO_STORE="yes"
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}"
rm -f gh_latest.json
if [[ "${SNAP_VERSION}" == "${GH_VERSION}" ]]; then
export SHOULD_DEPLOY="no"
else
export SHOULD_DEPLOY="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