Repository: FuelLabs/fuelup
Pull request #214 (2022-09-28 04:32:17)

refactor: deprecate append_package_to_channel
with #210 we no longer need this script to build channels.


Patch:
diff --git a/.github/workflows/scripts/append_package_to_channel.sh b/.github/workflows/scripts/append_package_to_channel.sh
deleted file mode 100755
index 5cedc540..00000000
--- a/.github/workflows/scripts/append_package_to_channel.sh
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/bin/bash
-set -e
-
-add_url_and_hash() {
-    _url="https://github.com/FuelLabs/$1/releases/download/$2/$3"
-    _err=$(curl -sSf "${_url}" -L -o "${3}" 2>&1)
-    if echo "$_err" | grep -q 404; then
-        printf "Could not download from %s - the release binary might not be ready yet. You can check if a binary is available here: https://github.com/FuelLabs/%s/releases/%s\n" "${_url}" "${1}" "${2}"
-        exit 1
-    fi
-    # shasum generates extra output so we take the first 64 bytes.
-    _hash=$(shasum -a 256 "$3" | head -c 64)
-    RETVAL="url = \"${_url}\"\nhash = \"${_hash}\"\n\n"
-}
-
-create_new_pkg() {
-    _header=$(printf "[pkg.%s]\nversion = \"%s\"\n" "${1}" "${2}")
-    RETVAL="$_header"
-}
-
-create_pkg_in_channel() {
-    CHANNEL_TOML_NAME=$3
-    version=$2
-    date="$(date +'%Y%m%d')"
-    tag="v${2}"
-    case "${1}" in
-        "forc")
-            _targets=("darwin_amd64" "darwin_arm64" "linux_amd64" "linux_arm64")
-            _repo="sway"
-            _tarball_prefix="forc-binaries"
-            ;;
-        "forc-client")
-            _targets=("aarch64-apple-darwin" "aarch64-unknown-linux-gnu" "x86_64-apple-darwin" "x86_64-unknown-linux-gnu")
-            _repo="forc-client"
-            _tarball_prefix="forc-client"
-
-            if [ "${2}" != "nightly" ]; then
-                _tarball_prefix+="-${version}"
-            fi
-            ;;
-        "fuel-core")
-            _targets=("aarch64-apple-darwin" "aarch64-unknown-linux-gnu" "x86_64-apple-darwin" "x86_64-unknown-linux-gnu")
-            _repo="fuel-core"
-            _tarball_prefix="fuel-core"
-
-            if [ "${2}" != "nightly" ]; then
-                _tarball_prefix+="-${version}"
-            fi
-
-            ;;
-    esac
-
-    if [ "${2}" = "nightly" ]; then
-        _repo="sway-nightly-binaries"
-        version="$(curl -s https://api.github.com/repos/FuelLabs/${_repo}/releases | grep "tag_name" | grep "nightly.${date}" | grep "${_tarball_prefix}" | head -n 1 | cut -d "-" -f3- | cut -d "\"" -f1)"
-        _tarball_prefix+="-${version}"
-        # Replace '+' within string with '%2B' to be URL friendly
-        tag=$(echo "${_tarball_prefix}" | sed -r "s/\+/\%2B/g")
-    fi
-
-    # We need to recreate channel-fuel-latest.toml, generating new URLs and sha256 hashes for the download links.
-    printf "%s: Generating new package\n" "${1}"
-    create_new_pkg "$1" "${version}"
-    _header="$RETVAL"
-    _content=""
-    for target in "${_targets[@]}"; do
-        _content+="[pkg.${1}.target.${target}]\n"
-        # TAG is either: v0.22.1 or forc-binaries-nightly-2022-08-25
-        add_url_and_hash $_repo "${tag}" "${_tarball_prefix}-${target}.tar.gz"
-        _content+="$RETVAL"
-    done
-
-    # Only write to file if there's no problem downloading and hashing all the above releases.
-    _package=$(printf "%s\n%s" "${_header}" "${_content}")
-    echo -ne "$_package" >>"$CHANNEL_TOML_NAME"
-}
-
-main() {
-    COMPONENT=$1
-    VERSION=$2
-    CHANNEL_TOML_NAME=$3
-    trap 'rm *.tar.gz' ERR EXIT
-
-    create_pkg_in_channel "${COMPONENT}" "${VERSION}" "${CHANNEL_TOML_NAME}"
-
-    exit 0
-}
-
-main "$@" || exit 1


Test patch:
diff --git a/.github/workflows/test-toolchain-compatibility.yml b/.github/workflows/test-toolchain-compatibility.yml
index b5a5fdef..fe1f6644 100644
--- a/.github/workflows/test-toolchain-compatibility.yml
+++ b/.github/workflows/test-toolchain-compatibility.yml
@@ -150,7 +150,7 @@ jobs:
       - name: Install build-channel script
         run: cargo install --debug --path ./ci/build-channel
 
-      # Generate the channel TOML file here and run append_package_to_channel.sh which appends download links and hashes for forc and fuel-core to the channel TOML.
+      # Generate the channel TOML file here and run build-channel script which appends download links and hashes for forc and fuel-core to the channel TOML.
       - name: Prepare channel with compatible versions
         if: ${{ env.LATEST_COMPATIBLE_FORC && env.LATEST_COMPATIBLE_FUEL_CORE }}
         run: |