From 3465153c6e720679ab0e2cc9d9eaf74c58ddcc29 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain Date: Thu, 8 Feb 2024 16:10:05 +0100 Subject: [PATCH] fix(snap): squash changes [skip ci] --- .github/workflows/insider-linux.yml | 55 ++++++++++++++++----------- .github/workflows/stable-linux.yml | 1 + .gitignore | 2 +- check_tags.sh | 21 ----------- prepare_assets.sh | 11 +----- stores/snapcraft/build.sh | 58 +++++++++++++++-------------- stores/snapcraft/check_version.sh | 45 +++++++++++----------- 7 files changed, 90 insertions(+), 103 deletions(-) diff --git a/.github/workflows/insider-linux.yml b/.github/workflows/insider-linux.yml index 39ed7b9..373053f 100644 --- a/.github/workflows/insider-linux.yml +++ b/.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' - - uses: diddlesnaps/snapcraft-multiarch-action@v1 - with: - path: stores/snapcraft/insider - architecture: ${{ matrix.platform }} - id: build - if: env.SHOULD_DEPLOY == 'yes' - - - uses: diddlesnaps/snapcraft-review-action@v1 - with: - snap: ${{ steps.build.outputs.snap }} - isClassic: 'true' - if: env.SHOULD_DEPLOY == 'yes' - - - uses: snapcore/action-publish@master + - name: Prepare snapcraft.yaml env: - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }} + 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: snapcore/action-build@v1 with: - snap: ${{ steps.build.outputs.snap }} - release: edge - if: env.SHOULD_DEPLOY == 'yes' + path: stores/snapcraft/out + id: build + if: env.SHOULD_BUILD == 'yes' + + # - uses: diddlesnaps/snapcraft-review-action@v1 + # with: + # snap: ${{ steps.build.outputs.snap }} + # isClassic: 'true' + # if: env.SHOULD_BUILD == 'yes' + + - uses: svenstaro/upload-release-action@v2 + with: + 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' diff --git a/.github/workflows/stable-linux.yml b/.github/workflows/stable-linux.yml index f5f6488..120061c 100644 --- a/.github/workflows/stable-linux.yml +++ b/.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: diff --git a/.gitignore b/.gitignore index b57aa23..7c9e280 100644 --- a/.gitignore +++ b/.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 diff --git a/check_tags.sh b/check_tags.sh index 3800815..826db66 100755 --- a/check_tags.sh +++ b/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}" diff --git a/prepare_assets.sh b/prepare_assets.sh index 1bbd803..fdee918 100755 --- a/prepare_assets.sh +++ b/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 diff --git a/stores/snapcraft/build.sh b/stores/snapcraft/build.sh index 47bf368..bec2d0b 100755 --- a/stores/snapcraft/build.sh +++ b/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}" diff --git a/stores/snapcraft/check_version.sh b/stores/snapcraft/check_version.sh index b824bc4..d327b67 100755 --- a/stores/snapcraft/check_version.sh +++ b/stores/snapcraft/check_version.sh @@ -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