mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-07 21:47:02 +09:00
refactored update-ci.sh and .github/workflows/build.yml
This commit is contained in:
parent
0c2826e81e
commit
ad99b6afb2
2 changed files with 130 additions and 77 deletions
43
.github/workflows/build.yml
vendored
43
.github/workflows/build.yml
vendored
|
@ -43,12 +43,12 @@ jobs:
|
|||
python-version: 3.11
|
||||
|
||||
- name: Install LibSecret
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
if: matrix.os == 'ubuntu-latest' # only for ubuntu 24 or latest
|
||||
run:
|
||||
sudo apt-get install libsecret-1-dev
|
||||
|
||||
- name: Install AzureSignTool
|
||||
if: matrix.os == 'windows-latest'
|
||||
if: ${{ startsWith(matrix.os, 'windows-') }}
|
||||
run: dotnet tool install --global AzureSignTool
|
||||
|
||||
- name: Check out Git repository
|
||||
|
@ -70,32 +70,33 @@ jobs:
|
|||
#- name: Update Deps
|
||||
# run: npm run build:deps
|
||||
|
||||
- name: Update Addon Windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
shell: bash
|
||||
run: ./update-ci.sh ${{secrets.USER}} ${{secrets.TOKEN}} ${{matrix.os}}
|
||||
|
||||
- name: Update Addon
|
||||
if: matrix.os != 'windows-latest'
|
||||
- name: Update Addon only AMD
|
||||
if: ${{ startsWith(matrix.os, 'windows-') }}
|
||||
shell: bash
|
||||
run: |
|
||||
./update-ci.sh ${{secrets.USER}} ${{secrets.TOKEN}} ${{matrix.os}} arm
|
||||
./update-ci.sh ${{secrets.USER}} ${{secrets.TOKEN}} ${{matrix.os}} amd
|
||||
./update-ci.sh --user="${{secrets.USER}}" --token="${{secrets.TOKEN}}" --os="${{matrix.os}}" --middleware-version="$( cat middleware.version )"
|
||||
|
||||
- name: Update Addon AMD and ARM
|
||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||
shell: bash
|
||||
run: |
|
||||
./update-ci.sh --user="${{secrets.USER}}" --token="${{secrets.TOKEN}}" --os="${{matrix.os}}" --middleware-version="$( cat middleware.version )" --arch="arm"
|
||||
./update-ci.sh --user="${{secrets.USER}}" --token="${{secrets.TOKEN}}" --os="${{matrix.os}}" --middleware-version="$( cat middleware.version )" --arch="amd"
|
||||
|
||||
- name: Build Native Messaging Host Windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
if: ${{ startsWith(matrix.os, 'windows-') }}
|
||||
run: npm run build:nmh-win
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
|
||||
- name: Build Native Messaging Host
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||
run: npm run build:nmh
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
|
||||
- name: Build Front Mac OS
|
||||
if: matrix.os == 'macos-13'
|
||||
if: ${{ startsWith(matrix.os, 'macos-') }}
|
||||
uses: samuelmeuli/action-electron-builder@v1
|
||||
with:
|
||||
github_token: ${{secrets.TOKEN}}
|
||||
|
@ -114,7 +115,7 @@ jobs:
|
|||
SENTRY_AUTH_TOKEN: ${{secrets.SENTRY_AUTH_TOKEN}}
|
||||
|
||||
- name: Build Front Other
|
||||
if: matrix.os != 'macos-13'
|
||||
if: ${{ !startsWith(matrix.os, 'macos-') }}
|
||||
uses: samuelmeuli/action-electron-builder@v1
|
||||
with:
|
||||
github_token: ${{secrets.TOKEN}}
|
||||
|
@ -136,12 +137,12 @@ jobs:
|
|||
mkdir -p artifacts
|
||||
|
||||
- name: Cleanup artifacts
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||
run: |
|
||||
mv dist/*.{zip,dmg,deb,AppImage,exe,snap,rpm,tar.gz} artifacts || true
|
||||
|
||||
- name: Cleanup artifacts Windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
if: ${{ startsWith(matrix.os, 'windows-') }}
|
||||
run: |
|
||||
rm dist/anytypeHelper.exe
|
||||
rm dist/nativeMessagingHost.exe
|
||||
|
@ -156,7 +157,7 @@ jobs:
|
|||
GITHUB_TOKEN: ${{secrets.TOKEN}}
|
||||
|
||||
- name: debug
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||
run: |
|
||||
echo "list dist/:"
|
||||
ls -alh dist/
|
||||
|
@ -164,14 +165,14 @@ jobs:
|
|||
ls -alh artifacts/
|
||||
|
||||
- name: debug Windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
if: ${{ startsWith(matrix.os, 'windows-') }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
Get-ChildItem -Path dist | Format-Table -Property Mode, LastWriteTime, Length, Name
|
||||
Get-ChildItem -Path artifacts | Format-Table -Property Mode, LastWriteTime, Length, Name
|
||||
|
||||
- name: Upload artifacts to HTTP server
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ !startsWith(matrix.os, 'windows-') }}
|
||||
run: |
|
||||
RELEASE_VERSION=$( echo "$GITHUB_REF_NAME" | perl -pe 's/^[a-zA-Z]+//' )
|
||||
cd artifacts/
|
||||
|
@ -194,7 +195,7 @@ jobs:
|
|||
done
|
||||
|
||||
- name: Upload artifacts to HTTP server Windows
|
||||
if: matrix.os == 'windows-latest'
|
||||
if: ${{ startsWith(matrix.os, 'windows-') }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$releaseVersion = $env:GITHUB_REF_NAME -replace '^[a-zA-Z]+', ''
|
||||
|
|
164
update-ci.sh
164
update-ci.sh
|
@ -1,71 +1,123 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# initialize variables
|
||||
USER=""
|
||||
TOKEN=""
|
||||
OS=""
|
||||
ARCH=""
|
||||
MIDDLEWARE_VERSION=""
|
||||
|
||||
do_usage(){
|
||||
cat <<EOF 1>&2
|
||||
|
||||
Usage: $0 --user=<GITHUB_USER> --token=<GITHUB_TOKEN> --os=<OS> --middleware-version=<VERSION> [--arch=<ARCH>]
|
||||
|
||||
Options:
|
||||
--user - github user
|
||||
--token - github token
|
||||
--os - operating system
|
||||
--arch - architecture (required only for os macos)
|
||||
--middleware-version - set middleware version
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
# process named arguments
|
||||
while [[ "$#" -gt 0 ]]; do
|
||||
case $1 in
|
||||
--user=*) USER="${1#*=}";;
|
||||
--token=*) TOKEN="${1#*=}";;
|
||||
--os=*) OS="${1#*=}";;
|
||||
--arch=*) ARCH="${1#*=}";;
|
||||
--middleware-version=*) MIDDLEWARE_VERSION="${1#*=}";;
|
||||
*)
|
||||
echo "Unknown argument: $1" 1>&2
|
||||
do_usage
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# check args
|
||||
if [[ -z $USER || -z $TOKEN || -z $OS || -z $MIDDLEWARE_VERSION ]]; then
|
||||
do_usage
|
||||
fi
|
||||
|
||||
REPO="anyproto/anytype-heart"
|
||||
FILE="addon.tar.gz"
|
||||
ARCHIVE_SUFFIX="tar.gz"
|
||||
GITHUB="api.github.com"
|
||||
if [[ "$OS" =~ ^ubuntu-.*$ ]]; then
|
||||
[[ -z "$ARCH" ]] && do_usage # required for this os
|
||||
OS_ARCH="linux-${ARCH}64"
|
||||
FOLDER="linux-${ARCH}"
|
||||
elif [[ "$OS" =~ ^macos-.*$ ]]; then
|
||||
[[ -z "$ARCH" ]] && do_usage # required for this os
|
||||
OS_ARCH="darwin-${ARCH}64"
|
||||
FOLDER="darwin-${ARCH}"
|
||||
elif [[ "$OS" =~ ^windows-.*$ ]]; then
|
||||
OS_ARCH="windows-amd64"
|
||||
FOLDER="dist"
|
||||
ARCHIVE_SUFFIX="zip"
|
||||
else
|
||||
echo "Unsupported OS='$OS'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
FILE="addon.$ARCHIVE_SUFFIX"
|
||||
|
||||
user=$1
|
||||
token=$2;
|
||||
platform=${3:-ubuntu-latest};
|
||||
arch=$4;
|
||||
folder="build";
|
||||
# debug
|
||||
cat <<EOF
|
||||
OS_ARCH=$OS_ARCH
|
||||
FOLDER=$FOLDER
|
||||
ARCHIVE_SUFFIX=$ARCHIVE_SUFFIX
|
||||
FILE=$FILE
|
||||
MIDDLEWARE_VERSION=$MIDDLEWARE_VERSION
|
||||
|
||||
if [ "$platform" = "ubuntu-latest" ] || [ "$platform" = "ubuntu-22.04" ]; then
|
||||
arch="linux-$arch";
|
||||
folder="$arch";
|
||||
elif [ "$platform" = "macos-13" ]; then
|
||||
arch="darwin-$arch";
|
||||
folder="$arch";
|
||||
elif [ "$platform" = "windows-latest" ]; then
|
||||
arch="windows";
|
||||
folder="dist";
|
||||
FILE="addon.zip"
|
||||
fi;
|
||||
EOF
|
||||
|
||||
echo "Arch: $arch"
|
||||
echo "Folder: $folder"
|
||||
echo ""
|
||||
if [[ $MIDDLEWARE_VERSION == "nightly" ]]; then
|
||||
ASSET="js_${MIDDLEWARE_VERSION}_${OS_ARCH}.${ARCHIVE_SUFFIX}"
|
||||
echo -n "Downloading file ${DOWNLOAD_ASSETS_URL}/$ASSET ..."
|
||||
curl --silent --location "${DOWNLOAD_ASSETS_URL}/$ASSET" > $FILE
|
||||
else
|
||||
VERSION=$(curl --silent --location --user "$USER:$TOKEN" --header "Accept: application/vnd.github.v3+json" "https://$GITHUB/repos/$REPO/releases/tags/v${MIDDLEWARE_VERSION}" | jq .)
|
||||
ASSET_ID=$(echo $VERSION | jq ".assets | map(select(.name | match(\"js_v[0-9]+.[0-9]+.[0-9]+(-rc[0-9]+)?_${OS_ARCH}\";\"i\")))[0].id")
|
||||
|
||||
if [ "$arch" = "" ]; then
|
||||
echo "ERROR: arch not found"
|
||||
exit 1
|
||||
fi;
|
||||
if [[ "$ASSET_ID" == "" ]]; then
|
||||
echo "ERROR: ASSET_ID not found in VERSION='$VERSION'" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mwv=`cat middleware.version`
|
||||
echo "Version: $VERSION"
|
||||
echo "Found asset: $ASSET_ID"
|
||||
echo -n "Downloading file $ASSET_ID ..."
|
||||
curl --silent --location --header "Authorization: token $TOKEN" --header "Accept: application/octet-stream" "https://$GITHUB/repos/$REPO/releases/assets/$ASSET_ID" > $FILE
|
||||
fi
|
||||
# check download status
|
||||
if [[ -s $FILE ]]; then
|
||||
echo " Done"
|
||||
else
|
||||
echo -e "\nERROR: failed download asset" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=`curl -u "$user:$token" -H "Accept: application/vnd.github.v3+json" -sL https://$GITHUB/repos/$REPO/releases/tags/v$mwv | jq .`
|
||||
if [[ "$OS" =~ ^windows-.*$ ]]; then
|
||||
echo -n "Uncompressing... "
|
||||
unzip $FILE || exit 1
|
||||
echo "Done"
|
||||
|
||||
tag=`echo $version | jq ".tag_name"`
|
||||
asset_id=`echo $version | jq ".assets | map(select(.name | match(\"js_v[0-9]+.[0-9]+.[0-9]+([^_]+)?_$arch\";\"i\")))[0].id"`
|
||||
echo "Moving... "
|
||||
mv -fv grpc-server.exe "$FOLDER/anytypeHelper.exe"
|
||||
else
|
||||
echo -n "Uncompressing... "
|
||||
tar -zxf $FILE || exit 1
|
||||
echo "Done"
|
||||
|
||||
if [ "$asset_id" = "" ]; then
|
||||
echo "ERROR: version not found"
|
||||
exit 1
|
||||
fi;
|
||||
|
||||
printf "Version: $tag\n"
|
||||
printf "Found asset: $asset_id\n"
|
||||
echo -n "Downloading file..."
|
||||
curl -sL -H "Authorization: token $token" -H 'Accept: application/octet-stream' "https://$GITHUB/repos/$REPO/releases/assets/$asset_id" > $FILE
|
||||
printf "Done\n"
|
||||
|
||||
if [ "$platform" = "windows-latest" ]; then
|
||||
echo -n "Uncompressing... "
|
||||
unzip $FILE
|
||||
printf "Done\n"
|
||||
|
||||
echo "Moving... "
|
||||
mv -fv grpc-server.exe "$folder/anytypeHelper.exe"
|
||||
else
|
||||
echo -n "Uncompressing... "
|
||||
tar -zxf $FILE
|
||||
printf "Done\n"
|
||||
|
||||
echo "Moving... "
|
||||
rm -rf "$folder"
|
||||
mkdir -p "$folder"
|
||||
mv -fv grpc-server "$folder/anytypeHelper"
|
||||
fi;
|
||||
echo "Moving... "
|
||||
rm -rf "$FOLDER"
|
||||
mkdir -p "$FOLDER"
|
||||
mv -fv grpc-server "$FOLDER/anytypeHelper"
|
||||
fi
|
||||
|
||||
rm -rf dist/lib/pb
|
||||
rm -rf dist/lib/pkg
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue