From e564685c1e53c9bc80ffed85d98ebcccd1f9d6e4 Mon Sep 17 00:00:00 2001 From: Baptiste Augrain <daiyam@zokugun.org> Date: Fri, 1 Oct 2021 18:47:10 +0200 Subject: [PATCH] feat: selective publish (#858) --- .editorconfig | 22 ++ .github/workflows/linux.yml | 48 ++--- .github/workflows/macos.yml | 47 ++--- .github/workflows/windows.yml | 46 +---- build.sh | 52 +++-- check_tags.sh | 370 ++++++++++++++++++++++------------ install_gh.sh | 15 ++ prepare_artifacts.sh | 92 +++++++++ release.sh | 27 +++ sum.sh | 28 --- update_version.sh | 102 +++++----- 11 files changed, 523 insertions(+), 326 deletions(-) create mode 100644 .editorconfig create mode 100755 install_gh.sh create mode 100755 prepare_artifacts.sh create mode 100755 release.sh delete mode 100755 sum.sh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8f0c97d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +tab_width = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.sh] +indent_style = space +indent_size = 2 + +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +[*.patch] +trim_trailing_whitespace = false +insert_final_newline = false diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 29de18b..6037b2d 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -11,7 +11,7 @@ on: jobs: linux: runs-on: ubuntu-latest - container: + container: image: ${{ matrix.image }} env: OS_NAME: 'linux' @@ -34,6 +34,9 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Install GH + run: ./install_gh.sh + - name: Setup Node.js environment uses: actions/setup-node@v1 with: @@ -42,12 +45,12 @@ jobs: - name: Install Yarn run: npm install -g yarn - - name: Check PR or cron - run: ./check_cron_or_pr.sh - - name: Clone VSCode repo run: ./get_repo.sh + - name: Check PR or cron + run: ./check_cron_or_pr.sh + - name: Check existing VSCodium tags/releases env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -79,42 +82,15 @@ jobs: run: ./build.sh if: env.SHOULD_BUILD == 'yes' - - name: Zip release - run: | - cd VSCode-linux-${VSCODE_ARCH} - tar czf ../VSCodium-linux-${VSCODE_ARCH}-${MS_TAG}.tar.gz . + - name: Prepare artifacts + run: ./prepare_artifacts.sh if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - - name: Move/rename build artifacts - shell: bash - run: | - cp vscode/.build/linux/deb/*/deb/*.deb . - cp vscode/.build/linux/rpm/*/*.rpm . - - if [[ "${VSCODE_ARCH}" == "x64" ]]; then - cp build/linux/appimage/out/*.AppImage* . - fi - if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - - - name: Generate shasums - run: ./sum.sh - if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - - name: Release - uses: softprops/action-gh-release@v1 - if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - with: - tag_name: ${{ env.MS_TAG }} - files: | - ./*.sha256 - ./*.zip - ./*.tar.gz - ./*.deb - ./*.rpm - ./VSCodium-*.AppImage - ./VSCodium-*.AppImage.zsync env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./release.sh + if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - name: Update versions repo if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index be70463..de5de59 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -11,7 +11,7 @@ on: jobs: build: runs-on: ${{ matrix.os }} - + strategy: fail-fast: false matrix: @@ -27,25 +27,22 @@ jobs: steps: - uses: actions/checkout@v2 - + - name: Setup Node.js environment uses: actions/setup-node@v1 with: node-version: 14 - - - name: Check PR or cron - run: | - . check_cron_or_pr.sh - name: Clone VSCode repo - run: | - . get_repo.sh + run: . get_repo.sh + + - name: Check PR or cron + run: . check_cron_or_pr.sh - name: Check existing VSCodium tags/releases env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - . check_tags.sh + run: . check_tags.sh if: env.SHOULD_DEPLOY == 'yes' - name: Compute cache key @@ -92,35 +89,15 @@ jobs: codesign --deep --force --verbose --sign "$CERTIFICATE_OSX_ID" VSCodium.app fi - - name: Zip release - run: | - cd "VSCode-darwin-${VSCODE_ARCH}" - zip -r -X -y ../VSCodium-darwin-${VSCODE_ARCH}-${MS_TAG}.zip ./*.app + - name: Prepare artifacts + run: ./prepare_artifacts.sh if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - - name: DMG the release - run: | - pushd "VSCode-darwin-${VSCODE_ARCH}" - npx create-dmg VSCodium.app .. - mv "../VSCodium ${MS_TAG}.dmg" "../VSCodium.${VSCODE_ARCH}.${MS_TAG}.dmg" - popd - if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - - - name: Generate shasums - run: ./sum.sh - if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - - name: Release - uses: softprops/action-gh-release@v1 - if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - with: - tag_name: ${{ env.MS_TAG }} - files: | - ./*.zip - ./*.dmg - ./*.sha256 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./release.sh + if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - name: Update versions repo if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 5c91731..4365493 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -11,6 +11,9 @@ on: jobs: windows: runs-on: windows-2016 + defaults: + run: + shell: bash env: VSCODE_ARCH: ${{ matrix.vscode_arch }} OS_NAME: 'windows' @@ -41,19 +44,16 @@ jobs: with: python-version: '2.x' - - name: Check PR or cron - run: ./check_cron_or_pr.sh - shell: bash - - name: Clone VSCode repo run: ./get_repo.sh - shell: bash + + - name: Check PR or cron + run: ./check_cron_or_pr.sh - name: Check existing VSCodium tags/releases env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./check_tags.sh - shell: bash if: env.SHOULD_DEPLOY == 'yes' - name: Compute cache key @@ -80,45 +80,21 @@ jobs: npm_config_arch: ${{ matrix.vscode_arch }} npm_config_target_arch: ${{ matrix.vscode_arch }} run: ./build.sh - shell: bash if: env.SHOULD_BUILD == 'yes' - - name: Move/rename build artifacts - run: | - mv vscode\\.build\\win32-${VSCODE_ARCH}\\system-setup\\VSCodeSetup.exe VSCodiumSetup-${VSCODE_ARCH}-${MS_TAG}.exe - mv vscode\\.build\\win32-${VSCODE_ARCH}\\user-setup\\VSCodeSetup.exe VSCodiumUserSetup-${VSCODE_ARCH}-${MS_TAG}.exe - mv vscode\\.build\\win32-${VSCODE_ARCH}\\archive\\VSCode-win32-${VSCODE_ARCH}.zip VSCodium-win32-${VSCODE_ARCH}-${MS_TAG}.zip - - if [[ "${VSCODE_ARCH}" == "ia32" || "${VSCODE_ARCH}" == "x64" ]]; then - mv build\\windows\\msi\\releasedir\\VSCodium-${VSCODE_ARCH}-${MS_TAG}.msi . - mv build\\windows\\msi\\releasedir\\VSCodium-${VSCODE_ARCH}-updates-disabled-${MS_TAG}.msi . - fi - shell: bash + - name: Prepare artifacts + run: ./prepare_artifacts.sh if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - - name: Generate shasums - run: ./sum.sh - shell: bash - if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - - name: Release - uses: softprops/action-gh-release@v1 - if: env.SHOULD_BUILD == 'yes' && env.SHOULD_DEPLOY == 'yes' - with: - tag_name: ${{ env.MS_TAG }} - files: | - ./*.sha256 - ./VSCodium*.zip - ./VSCodiumUserSetup*.exe - ./VSCodiumSetup*.exe - ./VSCodium*.msi env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./release.sh + 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 - shell: bash env: GITHUB_TOKEN: ${{ secrets.STRONGER_GITHUB_TOKEN }} GITHUB_USERNAME: ${{ github.repository_owner }} diff --git a/build.sh b/build.sh index 2244f97..2d7a60d 100755 --- a/build.sh +++ b/build.sh @@ -2,7 +2,7 @@ set -ex -if [[ "$SHOULD_BUILD" == "yes" ]]; then +if [[ "${SHOULD_BUILD}" == "yes" ]]; then npm config set scripts-prepend-node-path true echo "MS_COMMIT: ${MS_COMMIT}" @@ -19,29 +19,51 @@ if [[ "$SHOULD_BUILD" == "yes" ]]; then yarn gulp compile-extensions-build yarn gulp minify-vscode - if [[ "$OS_NAME" == "osx" ]]; then + if [[ "${OS_NAME}" == "osx" ]]; then yarn gulp "vscode-darwin-${VSCODE_ARCH}-min-ci" - elif [[ "$OS_NAME" == "windows" ]]; then + elif [[ "${OS_NAME}" == "windows" ]]; then . ../build/windows/rtf/make.sh - + yarn gulp "vscode-win32-${VSCODE_ARCH}-min-ci" yarn gulp "vscode-win32-${VSCODE_ARCH}-code-helper" yarn gulp "vscode-win32-${VSCODE_ARCH}-inno-updater" - yarn gulp "vscode-win32-${VSCODE_ARCH}-archive" - yarn gulp "vscode-win32-${VSCODE_ARCH}-system-setup" - yarn gulp "vscode-win32-${VSCODE_ARCH}-user-setup" - + + if [[ "${SHOULD_BUILD_ZIP}" != "no" ]]; then + yarn gulp "vscode-win32-${VSCODE_ARCH}-archive" + fi + + if [[ "${SHOULD_BUILD_EXE_SYS}" != "no" ]]; then + yarn gulp "vscode-win32-${VSCODE_ARCH}-system-setup" + fi + + if [[ "${SHOULD_BUILD_EXE_USR}" != "no" ]]; then + yarn gulp "vscode-win32-${VSCODE_ARCH}-user-setup" + fi + if [[ "${VSCODE_ARCH}" == "ia32" || "${VSCODE_ARCH}" == "x64" ]]; then - . ../build/windows/msi/build.sh - . ../build/windows/msi/build-updates-disabled.sh + if [[ "${SHOULD_BUILD_MSI}" != "no" ]]; then + . ../build/windows/msi/build.sh + fi + + if [[ "${SHOULD_BUILD_MSI_NOUP}" != "no" ]]; then + . ../build/windows/msi/build-updates-disabled.sh + fi fi else # linux yarn gulp "vscode-linux-${VSCODE_ARCH}-min-ci" - if [[ "$SKIP_LINUX_PACKAGES" != "True" ]]; then - yarn gulp "vscode-linux-${VSCODE_ARCH}-build-deb" - yarn gulp "vscode-linux-${VSCODE_ARCH}-build-rpm" - - . ../build/linux/appimage/build.sh + + if [[ "${SKIP_LINUX_PACKAGES}" != "True" ]]; then + if [[ "${SHOULD_BUILD_DEB}" != "no" || "${SHOULD_BUILD_APPIMAGE}" != "no" ]]; then + yarn gulp "vscode-linux-${VSCODE_ARCH}-build-deb" + fi + + if [[ "${SHOULD_BUILD_RPM}" != "no" ]]; then + yarn gulp "vscode-linux-${VSCODE_ARCH}-build-rpm" + fi + + if [[ "${SHOULD_BUILD_APPIMAGE}" != "no" ]]; then + . ../build/linux/appimage/build.sh + fi fi fi diff --git a/check_tags.sh b/check_tags.sh index f1144d3..baec5c7 100755 --- a/check_tags.sh +++ b/check_tags.sh @@ -2,147 +2,259 @@ set -e +if [[ -z "${GITHUB_TOKEN}" ]]; then + echo "Will not build because no GITHUB_TOKEN defined" + exit +fi + REPOSITORY="${GITHUB_REPOSITORY:-"VSCodium/vscodium"}" -GITHUB_RESPONSE=$( curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/$REPOSITORY/releases/tags/$MS_TAG) -VSCODIUM_ASSETS=$( echo $GITHUB_RESPONSE | jq -c '.assets | map(.name)?' ) +GITHUB_RESPONSE=$( curl -s -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/${REPOSITORY}/releases/tags/${MS_TAG}) +VSCODIUM_ASSETS=$( echo "${GITHUB_RESPONSE}" | jq -c '.assets | map(.name)?' ) contains() { # add " to match the end of a string so any hashs won't be matched by mistake - echo $VSCODIUM_ASSETS | grep "$1\"" + echo "${VSCODIUM_ASSETS}" | grep "$1\"" } -# if we just don't have the github token, get out fast -if [ "$GITHUB_TOKEN" != "" ]; then - if [ "$VSCODIUM_ASSETS" != "null" ]; then - # macos - if [[ "$OS_NAME" == "osx" ]]; then - if [[ -z $( contains "darwin-$VSCODE_ARCH-$MS_TAG.zip" ) ]]; then - echo "Building on Mac because we have no ZIP" +if [ "${VSCODIUM_ASSETS}" != "null" ]; then + # macos + if [[ "${OS_NAME}" == "osx" ]]; then + if [[ -z $( contains "darwin-${VSCODE_ARCH}-${MS_TAG}.zip" ) ]]; then + echo "Building on MacOS because we have no ZIP" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_ZIP="no" + fi + + if [[ -z $( contains ".${VSCODE_ARCH}.${MS_TAG}.dmg" ) ]]; then + echo "Building on MacOS because we have no DMG" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_DMG="no" + fi + + if [[ "${SHOULD_BUILD}" != "yes" ]]; then + echo "Already have all the MacOS builds" + fi + elif [[ "${OS_NAME}" == "windows" ]]; then + + # windows-arm64 + if [[ ${VSCODE_ARCH} == "arm64" ]]; then + if [[ -z $( contains "VSCodiumSetup-${VSCODE_ARCH}-${MS_TAG}.exe" ) ]]; then + echo "Building on Windows arm64 because we have no system setup" export SHOULD_BUILD="yes" - fi - elif [[ "$OS_NAME" == "windows" ]]; then - # windows-arm64 - if [[ $VSCODE_ARCH == "arm64" ]]; then - if [[ -z $( contains "VSCodiumSetup-$VSCODE_ARCH-$MS_TAG.exe" ) ]]; then - echo "Building on Windows arm64 because we have no system setup" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "UserSetup-$VSCODE_ARCH-$MS_TAG.exe" ) ]]; then - echo "Building on Windows arm64 because we have no user setup" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "win32-$VSCODE_ARCH-$MS_TAG.zip" ) ]]; then - echo "Building on Windows arm64 because we have no zip" - export SHOULD_BUILD="yes" - fi - if [[ "$SHOULD_BUILD" != "yes" ]]; then - echo "Already have all the Windows arm64 builds" - fi - # windows-ia32 - elif [[ $VSCODE_ARCH == "ia32" ]]; then - if [[ -z $( contains "VSCodiumSetup-$VSCODE_ARCH-$MS_TAG.exe" ) ]]; then - echo "Building on Windows ia32 because we have no system setup" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "UserSetup-$VSCODE_ARCH-$MS_TAG.exe" ) ]]; then - echo "Building on Windows ia32 because we have no user setup" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "win32-$VSCODE_ARCH-$MS_TAG.zip" ) ]]; then - echo "Building on Windows ia32 because we have no zip" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "VSCodium-$VSCODE_ARCH-$MS_TAG.msi" ) ]]; then - echo "Building on Windows ia32 because we have no msi" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "VSCodium-$VSCODE_ARCH-updates-disabled-$MS_TAG.msi" ) ]]; then - echo "Building on Windows ia32 because we have no updates-disabled msi" - export SHOULD_BUILD="yes" - fi - if [[ "$SHOULD_BUILD" != "yes" ]]; then - echo "Already have all the Windows ia32 builds" - fi - # windows-x64 else - if [[ -z $( contains "VSCodiumSetup-$VSCODE_ARCH-$MS_TAG.exe" ) ]]; then - echo "Building on Windows x64 because we have no system setup" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "UserSetup-$VSCODE_ARCH-$MS_TAG.exe" ) ]]; then - echo "Building on Windows x64 because we have no user setup" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "win32-$VSCODE_ARCH-$MS_TAG.zip" ) ]]; then - echo "Building on Windows x64 because we have no zip" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "VSCodium-$VSCODE_ARCH-$MS_TAG.msi" ) ]]; then - echo "Building on Windows x64 because we have no msi" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "VSCodium-$VSCODE_ARCH-updates-disabled-$MS_TAG.msi" ) ]]; then - echo "Building on Windows x64 because we have no updates-disabled msi" - export SHOULD_BUILD="yes" - fi - if [[ "$SHOULD_BUILD" != "yes" ]]; then - echo "Already have all the Windows x64 builds" - fi + export SHOULD_BUILD_EXE_SYS="no" fi - elif [[ "$OS_NAME" == "linux" ]]; then - # linux-arm64 - if [[ $VSCODE_ARCH == "arm64" ]]; then - if [[ -z $( contains "arm64.deb" ) ]]; then - echo "Building on Linux arm64 because we have no DEB" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "arm64-$MS_TAG.tar.gz" ) ]]; then - echo "Building on Linux arm64 because we have no TAR" - export SHOULD_BUILD="yes" - fi - if [[ "$SHOULD_BUILD" != "yes" ]]; then - echo "Already have all the Linux arm64 builds" - fi - # linux-armhf - elif [[ $VSCODE_ARCH == "armhf" ]]; then - if [[ -z $( contains "armhf.deb" ) ]]; then - echo "Building on Linux arm because we have no DEB" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "armhf-${MS_TAG}.tar.gz" ) ]]; then - echo "Building on Linux arm because we have no TAR" - export SHOULD_BUILD="yes" - fi - if [[ "$SHOULD_BUILD" != "yes" ]]; then - echo "Already have all the Linux arm builds" - fi - # linux-x64 + + if [[ -z $( contains "UserSetup-${VSCODE_ARCH}-${MS_TAG}.exe" ) ]]; then + echo "Building on Windows arm64 because we have no user setup" + export SHOULD_BUILD="yes" else - if [[ -z $( contains "x86_64.rpm" ) ]]; then - echo "Building on Linux x64 because we have no RPM" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "amd64.deb" ) ]]; then - echo "Building on Linux x64 because we have no DEB" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "x64-$MS_TAG.tar.gz" ) ]]; then - echo "Building on Linux x64 because we have no TAR" - export SHOULD_BUILD="yes" - fi - if [[ -z $( contains "x86_64.AppImage" ) ]]; then - echo "Building on Linux x64 because we have no AppImage" - export SHOULD_BUILD="yes" - fi - if [[ "$SHOULD_BUILD" != "yes" ]]; then - echo "Already have all the Linux x64 builds" - fi + export SHOULD_BUILD_EXE_USR="no" + fi + + if [[ -z $( contains "win32-${VSCODE_ARCH}-${MS_TAG}.zip" ) ]]; then + echo "Building on Windows arm64 because we have no zip" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_ZIP="no" + fi + + if [[ "${SHOULD_BUILD}" != "yes" ]]; then + echo "Already have all the Windows arm64 builds" + fi + + # windows-ia32 + elif [[ ${VSCODE_ARCH} == "ia32" ]]; then + if [[ -z $( contains "VSCodiumSetup-${VSCODE_ARCH}-${MS_TAG}.exe" ) ]]; then + echo "Building on Windows ia32 because we have no system setup" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_EXE_SYS="no" + fi + + if [[ -z $( contains "UserSetup-${VSCODE_ARCH}-${MS_TAG}.exe" ) ]]; then + echo "Building on Windows ia32 because we have no user setup" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_EXE_USR="no" + fi + + if [[ -z $( contains "win32-${VSCODE_ARCH}-${MS_TAG}.zip" ) ]]; then + echo "Building on Windows ia32 because we have no zip" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_ZIP="no" + fi + + if [[ -z $( contains "VSCodium-${VSCODE_ARCH}-${MS_TAG}.msi" ) ]]; then + echo "Building on Windows ia32 because we have no msi" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_MSI="no" + fi + + if [[ -z $( contains "VSCodium-${VSCODE_ARCH}-updates-disabled-${MS_TAG}.msi" ) ]]; then + echo "Building on Windows ia32 because we have no updates-disabled msi" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_MSI_NOUP="no" + fi + + if [[ "${SHOULD_BUILD}" != "yes" ]]; then + echo "Already have all the Windows ia32 builds" + fi + + # windows-x64 + else + if [[ -z $( contains "VSCodiumSetup-${VSCODE_ARCH}-${MS_TAG}.exe" ) ]]; then + echo "Building on Windows x64 because we have no system setup" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_EXE_SYS="no" + fi + + if [[ -z $( contains "UserSetup-${VSCODE_ARCH}-${MS_TAG}.exe" ) ]]; then + echo "Building on Windows x64 because we have no user setup" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_EXE_USR="no" + fi + + if [[ -z $( contains "win32-${VSCODE_ARCH}-${MS_TAG}.zip" ) ]]; then + echo "Building on Windows x64 because we have no zip" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_ZIP="no" + fi + + if [[ -z $( contains "VSCodium-${VSCODE_ARCH}-${MS_TAG}.msi" ) ]]; then + echo "Building on Windows x64 because we have no msi" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_MSI="no" + fi + + if [[ -z $( contains "VSCodium-${VSCODE_ARCH}-updates-disabled-${MS_TAG}.msi" ) ]]; then + echo "Building on Windows x64 because we have no updates-disabled msi" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_MSI_NOUP="no" + fi + + if [[ "${SHOULD_BUILD}" != "yes" ]]; then + echo "Already have all the Windows x64 builds" + fi + fi + elif [[ "${OS_NAME}" == "linux" ]]; then + + # linux-arm64 + if [[ ${VSCODE_ARCH} == "arm64" ]]; then + if [[ -z $( contains "arm64.deb" ) ]]; then + echo "Building on Linux arm64 because we have no DEB" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_DEB="no" + fi + + if [[ -z $( contains "aarch64.rpm" ) ]]; then + echo "Building on Linux arm64 because we have no RPM" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_RPM="no" + fi + + if [[ -z $( contains "arm64-${MS_TAG}.tar.gz" ) ]]; then + echo "Building on Linux arm64 because we have no TAR" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_TAR="no" + fi + + export SHOULD_BUILD_APPIMAGE="no" + + if [[ "${SHOULD_BUILD}" != "yes" ]]; then + echo "Already have all the Linux arm64 builds" + fi + + # linux-armhf + elif [[ ${VSCODE_ARCH} == "armhf" ]]; then + if [[ -z $( contains "armhf.deb" ) ]]; then + echo "Building on Linux arm because we have no DEB" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_DEB="no" + fi + + if [[ -z $( contains "armhf.rpm" ) ]]; then + echo "Building on Linux arm because we have no RPM" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_RPM="no" + fi + + if [[ -z $( contains "armhf-${MS_TAG}.tar.gz" ) ]]; then + echo "Building on Linux arm because we have no TAR" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_TAR="no" + fi + + export SHOULD_BUILD_APPIMAGE="no" + + if [[ "${SHOULD_BUILD}" != "yes" ]]; then + echo "Already have all the Linux arm builds" + fi + + # linux-x64 + else + if [[ -z $( contains "amd64.deb" ) ]]; then + echo "Building on Linux x64 because we have no DEB" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_DEB="no" + fi + + if [[ -z $( contains "x86_64.rpm" ) ]]; then + echo "Building on Linux x64 because we have no RPM" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_RPM="no" + fi + + if [[ -z $( contains "x64-${MS_TAG}.tar.gz" ) ]]; then + echo "Building on Linux x64 because we have no TAR" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_TAR="no" + fi + + if [[ -z $( contains "x86_64.AppImage" ) ]]; then + echo "Building on Linux x64 because we have no AppImage" + export SHOULD_BUILD="yes" + else + export SHOULD_BUILD_APPIMAGE="no" + fi + + if [[ "${SHOULD_BUILD}" != "yes" ]]; then + echo "Already have all the Linux x64 builds" fi fi - else - echo "Release assets do not exist at all, continuing build" - export SHOULD_BUILD="yes" fi +else + echo "Release assets do not exist at all, continuing build" + export SHOULD_BUILD="yes" fi -echo "SHOULD_BUILD=$SHOULD_BUILD" >> $GITHUB_ENV +echo "SHOULD_BUILD=${SHOULD_BUILD}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_APPIMAGE=${SHOULD_BUILD_APPIMAGE}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_DEB=${SHOULD_BUILD_DEB}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_DMG=${SHOULD_BUILD_DMG}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_EXE_SYS=${SHOULD_BUILD_EXE_SYS}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_EXE_USR=${SHOULD_BUILD_EXE_USR}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_MSI=${SHOULD_BUILD_MSI}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_MSI_NOUP=${SHOULD_BUILD_MSI_NOUP}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_RPM=${SHOULD_BUILD_RPM}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_TAR=${SHOULD_BUILD_TAR}" >> "${GITHUB_ENV}" +echo "SHOULD_BUILD_ZIP=${SHOULD_BUILD_ZIP}" >> "${GITHUB_ENV}" diff --git a/install_gh.sh b/install_gh.sh new file mode 100755 index 0000000..a829ada --- /dev/null +++ b/install_gh.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +GH_ARCH="amd64" + +VERSION=`curl "https://api.github.com/repos/cli/cli/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2-` + +curl -sSL "https://github.com/cli/cli/releases/download/v${VERSION}/gh_${VERSION}_linux_${GH_ARCH}.tar.gz" -o "gh_${VERSION}_linux_${GH_ARCH}.tar.gz" + +tar xf "gh_${VERSION}_linux_${GH_ARCH}.tar.gz" + +cp "gh_${VERSION}_linux_${GH_ARCH}/bin/gh" /usr/local/bin/ + +gh --version diff --git a/prepare_artifacts.sh b/prepare_artifacts.sh new file mode 100755 index 0000000..3bef953 --- /dev/null +++ b/prepare_artifacts.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +set -e + +npm install -g checksum + +sum_file() { + if [[ -f "$1" ]]; then + echo "Calcuating checksum for $1" + checksum -a sha256 "$1" > "$1".sha256 + checksum "$1" > "$1".sha1 + fi +} + +mkdir artifacts + +if [[ "${OS_NAME}" == "osx" ]]; then + if [[ "${SHOULD_BUILD_ZIP}" != "no" ]]; then + echo "Building and moving ZIP" + cd "VSCode-darwin-${VSCODE_ARCH}" + zip -r -X -y ../artifacts/VSCodium-darwin-${VSCODE_ARCH}-${MS_TAG}.zip ./*.app + cd .. + fi + + if [[ "${SHOULD_BUILD_DMG}" != "no" ]]; then + echo "Building and moving DMG" + pushd "VSCode-darwin-${VSCODE_ARCH}" + npx create-dmg VSCodium.app .. + mv "../VSCodium ${MS_TAG}.dmg" "../artifacts/VSCodium.${VSCODE_ARCH}.${MS_TAG}.dmg" + popd + fi +elif [[ "${OS_NAME}" == "windows" ]]; then + if [[ "${SHOULD_BUILD_ZIP}" != "no" ]]; then + echo "Moving ZIP" + mv vscode\\.build\\win32-${VSCODE_ARCH}\\archive\\VSCode-win32-${VSCODE_ARCH}.zip artifacts\\VSCodium-win32-${VSCODE_ARCH}-${MS_TAG}.zip + fi + + if [[ "${SHOULD_BUILD_EXE_SYS}" != "no" ]]; then + echo "Moving System EXE" + mv vscode\\.build\\win32-${VSCODE_ARCH}\\system-setup\\VSCodeSetup.exe artifacts\\VSCodiumSetup-${VSCODE_ARCH}-${MS_TAG}.exe + fi + + if [[ "${SHOULD_BUILD_EXE_USR}" != "no" ]]; then + echo "Moving User EXE" + mv vscode\\.build\\win32-${VSCODE_ARCH}\\user-setup\\VSCodeSetup.exe artifacts\\VSCodiumUserSetup-${VSCODE_ARCH}-${MS_TAG}.exe + fi + + if [[ "${VSCODE_ARCH}" == "ia32" || "${VSCODE_ARCH}" == "x64" ]]; then + if [[ "${SHOULD_BUILD_MSI}" != "no" ]]; then + echo "Moving MSI" + mv build\\windows\\msi\\releasedir\\VSCodium-${VSCODE_ARCH}-${MS_TAG}.msi artifacts/ + fi + + if [[ "${SHOULD_BUILD_MSI_NOUP}" != "no" ]]; then + echo "Moving MSI with disabled updates" + mv build\\windows\\msi\\releasedir\\VSCodium-${VSCODE_ARCH}-updates-disabled-${MS_TAG}.msi artifacts/ + fi + fi +else + if [[ "${SHOULD_BUILD_TAR}" != "no" ]]; then + echo "Building and moving TAR" + cd VSCode-linux-${VSCODE_ARCH} + tar czf ../artifacts/VSCodium-linux-${VSCODE_ARCH}-${MS_TAG}.tar.gz . + cd .. + fi + + if [[ "${SHOULD_BUILD_DEB}" != "no" ]]; then + echo "Moving DEB" + mv vscode/.build/linux/deb/*/deb/*.deb artifacts/ + fi + + if [[ "${SHOULD_BUILD_RPM}" != "no" ]]; then + echo "Moving RPM" + mv vscode/.build/linux/rpm/*/*.rpm artifacts/ + fi + + if [[ "${SHOULD_BUILD_APPIMAGE}" != "no" ]]; then + echo "Moving AppImage" + mv build/linux/appimage/out/*.AppImage* artifacts/ + fi +fi + +cd artifacts + +for FILE in * +do + if [[ -f "${FILE}" ]]; then + sum_file "${FILE}" + fi +done + +cd .. diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..1833ca5 --- /dev/null +++ b/release.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +set -e + +if [[ -z "${GH_CLI_TOKEN}" ]]; then + echo "Will not release because no GH_CLI_TOKEN defined" + exit +fi + +echo "${GH_CLI_TOKEN}" | gh auth login --with-token + +if [[ $( gh release view "${MS_TAG}" 2>&1 ) =~ "release not found" ]]; then + echo "Creating release '${MS_TAG}'" + gh release create "${MS_TAG}" +fi + +cd artifacts + +for FILE in * +do + if [[ -f "${FILE}" ]] && [[ "${FILE}" != *.sha1 ]] && [[ "${FILE}" != *.sha256 ]]; then + echo "Uploading '${FILE}'" + gh release upload "${MS_TAG}" "${FILE}" "${FILE}.sha1" "${FILE}.sha256" + fi +done + +cd .. diff --git a/sum.sh b/sum.sh deleted file mode 100755 index 881eae8..0000000 --- a/sum.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -npm install -g checksum - -sum_file () { - if [[ -f "$1" ]]; then - checksum -a sha256 "$1" > "$1".sha256 - checksum "$1" > "$1".sha1 - fi -} - -if [[ "$SHOULD_BUILD" == "yes" ]]; then - if [[ "$OS_NAME" == "osx" ]]; then - sum_file VSCodium-darwin-*.zip - sum_file VSCodium*.dmg - elif [[ "$OS_NAME" == "windows" ]]; then - sum_file VSCodiumSetup-*.exe - sum_file VSCodiumUserSetup-*.exe - sum_file VSCodium-win32-*.zip - sum_file "VSCodium-${VSCODE_ARCH}-${MS_TAG}.msi" - sum_file "VSCodium-${VSCODE_ARCH}-updates-disabled-${MS_TAG}.msi" - else # linux - sum_file VSCodium-*.AppImage - sum_file VSCodium-linux*.tar.gz - sum_file *.deb - sum_file *.rpm - fi -fi diff --git a/update_version.sh b/update_version.sh index f68c112..8de2fac 100755 --- a/update_version.sh +++ b/update_version.sh @@ -1,10 +1,17 @@ #!/bin/bash -if [[ "$SHOULD_BUILD" != "yes" ]]; then +set -e + +if [[ "${SHOULD_BUILD}" != "yes" ]]; then echo "Will not update version JSON because we did not build" exit fi +if [[ -z "${GITHUB_TOKEN}" ]]; then + echo "Will not update version JSON because no GITHUB_TOKEN defined" + exit +fi + # { # "url": "https://az764295.vo.msecnd.net/stable/51b0b28134d51361cf996d2f0a1c698247aeabd8/VSCode-darwin-stable.zip", # "name": "1.33.1", @@ -24,37 +31,40 @@ fi # `timestamp` is $(node -e 'console.log(Date.now())') # `sha256hash` in <filename>.sha256 -URL_BASE=https://github.com/VSCodium/vscodium/releases/download/${MS_TAG} +URL_BASE="https://github.com/VSCodium/vscodium/releases/download/${MS_TAG}" # to make testing on forks easier VERSIONS_REPO="${GITHUB_USERNAME}/versions" -echo "Versions repo:" $VERSIONS_REPO +echo "Versions repo: ${VERSIONS_REPO}" -# generateJson <assetName> -# e.g. generateJson VSCodium-darwin-1.33.0.zip generateJson() { - local assetName=$1 + JSON_DATA="{}" # generate parts - local url=${URL_BASE}/${assetName} - local name=$MS_TAG - local version=$MS_COMMIT - local productVersion=$MS_TAG + local url="${URL_BASE}/${ASSET_NAME}" + local name="${MS_TAG}" + local version="${MS_COMMIT}" + local productVersion="${MS_TAG}" local timestamp=$(node -e 'console.log(Date.now())') - local sha1hash=$(cat ${assetName}.sha1 | awk '{ print $1 }') - local sha256hash=$(cat ${assetName}.sha256 | awk '{ print $1 }') + if [[ ! -f "artifacts/${ASSET_NAME}" ]]; then + echo "Downloading artifact '${ASSET_NAME}'" + gh release download "${MS_TAG}" --dir "artifacts" --pattern "${ASSET_NAME}*" + fi + + local sha1hash=$(cat "artifacts/${ASSET_NAME}.sha1" | awk '{ print $1 }') + local sha256hash=$(cat "artifacts/${ASSET_NAME}.sha256" | awk '{ print $1 }') # check that nothing is blank (blank indicates something awry with build) for key in url name version productVersion sha1hash timestamp sha256hash; do - if [[ "${!key}" == "" ]]; then - echo "Missing data for version update; exiting..." + if [[ -z "${key}" ]]; then + echo "Variable '${key}' is empty; exiting..." exit 1 fi done # generate json - local json=$(jq \ + JSON_DATA=$(jq \ --arg url "${url}" \ --arg name "${name}" \ --arg version "${version}" \ @@ -64,70 +74,62 @@ generateJson() { --arg sha256hash "${sha256hash}" \ '. | .url=$url | .name=$name | .version=$version | .productVersion=$productVersion | .hash=$hash | .timestamp=$timestamp | .sha256hash=$sha256hash' \ <<<'{}') - - echo "$json" } updateLatestVersion() { + echo "Generating ${VERSION_PATH}/latest.json" + + generateJson + cd versions - local versionPath=$1 - local json=$2 - # create/update the latest.json file in the correct location - mkdir -p $versionPath - echo $json > $versionPath/latest.json + mkdir -p "${VERSION_PATH}" + echo "${JSON_DATA}" > "${VERSION_PATH}/latest.json" cd .. } # init versions repo for later commiting + pushing the json file to it # thank you https://www.vinaygopinath.me/blog/tech/commit-to-master-branch-on-github-using-travis-ci/ -git clone https://github.com/${VERSIONS_REPO}.git +git clone "https://github.com/${VERSIONS_REPO}.git" cd versions git config user.email "vscodium-ci@not-real.com" git config user.name "VSCodium CI" git remote rm origin -git remote add origin https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${VERSIONS_REPO}.git > /dev/null 2>&1 +git remote add origin "https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/${VERSIONS_REPO}.git" > /dev/null 2>&1 cd .. -if [[ "$OS_NAME" == "osx" ]]; then - # zip, sha1, and sha256 files are all at top level dir +if [[ "${OS_NAME}" == "osx" ]]; then ASSET_NAME=VSCodium-darwin-${VSCODE_ARCH}-${MS_TAG}.zip VERSION_PATH="darwin/${VSCODE_ARCH}" - JSON="$(generateJson ${ASSET_NAME})" - updateLatestVersion "$VERSION_PATH" "$JSON" -elif [[ "$OS_NAME" == "windows" ]]; then + updateLatestVersion +elif [[ "${OS_NAME}" == "windows" ]]; then # system installer ASSET_NAME=VSCodiumSetup-${VSCODE_ARCH}-${MS_TAG}.exe VERSION_PATH="win32/${VSCODE_ARCH}/system" - JSON="$(generateJson ${ASSET_NAME})" - updateLatestVersion "$VERSION_PATH" "$JSON" + updateLatestVersion # user installer ASSET_NAME=VSCodiumUserSetup-${VSCODE_ARCH}-${MS_TAG}.exe VERSION_PATH="win32/${VSCODE_ARCH}/user" - JSON="$(generateJson ${ASSET_NAME})" - updateLatestVersion "$VERSION_PATH" "$JSON" + updateLatestVersion # windows archive ASSET_NAME=VSCodium-win32-${VSCODE_ARCH}-${MS_TAG}.zip VERSION_PATH="win32/${VSCODE_ARCH}/archive" - JSON="$(generateJson ${ASSET_NAME})" - updateLatestVersion "$VERSION_PATH" "$JSON" - + updateLatestVersion + if [[ "${VSCODE_ARCH}" == "ia32" || "${VSCODE_ARCH}" == "x64" ]]; then # msi ASSET_NAME=VSCodium-${VSCODE_ARCH}-${MS_TAG}.msi VERSION_PATH="win32/${VSCODE_ARCH}/msi" - JSON="$(generateJson ${ASSET_NAME})" - updateLatestVersion "$VERSION_PATH" "$JSON" - + updateLatestVersion + # updates-disabled msi ASSET_NAME=VSCodium-${VSCODE_ARCH}-updates-disabled-${MS_TAG}.msi VERSION_PATH="win32/${VSCODE_ARCH}/msi-updates-disabled" - JSON="$(generateJson ${ASSET_NAME})" - updateLatestVersion "$VERSION_PATH" "$JSON" + updateLatestVersion fi else # linux # update service links to tar.gz file @@ -135,19 +137,23 @@ else # linux # as examples ASSET_NAME=VSCodium-linux-${VSCODE_ARCH}-${MS_TAG}.tar.gz VERSION_PATH="linux/${VSCODE_ARCH}" - JSON="$(generateJson ${ASSET_NAME})" - updateLatestVersion "$VERSION_PATH" "$JSON" + updateLatestVersion fi cd versions git pull origin master # in case another build just pushed git add . -dateAndMonth=`date "+%D %T"` -git commit -m "CI update: $dateAndMonth (Build $GITHUB_RUN_NUMBER)" -if ! git push origin master --quiet; then - git pull origin master - git push origin master --quiet + +CHANGES=$( git status --porcelain ) + +if [[ ! -z "${CHANGES}" ]]; then + dateAndMonth=$( date "+%D %T" ) + git commit -m "CI update: ${dateAndMonth} (Build ${GITHUB_RUN_NUMBER})" + if ! git push origin master --quiet; then + git pull origin master + git push origin master --quiet + fi fi cd ..