Skip to content

Get rid of artifacts #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 23, 2025
Prev Previous commit
Next Next commit
extra: package_tool.sh: add script to build and package tools in dist…
…rib/
  • Loading branch information
pillo79 committed Apr 17, 2025
commit b0aa14b10c74282b01eb36b62e6562c1b436e187
2 changes: 1 addition & 1 deletion .github/workflows/package_core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ env.CORE_ARTIFACT }}
path: ${{ env.CORE_ARTIFACT }}.tar.bz2
path: distrib/${{ env.CORE_ARTIFACT }}.tar.bz2

test-core:
name: Test ${{ matrix.board }} board
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extra/post_build_tool/distrib/
build/
distrib/
venv/
ArduinoCore-zephyr-*.tar.bz2
3 changes: 2 additions & 1 deletion extra/package_core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ extra/get_board_details.sh | jq -cr '.[]' | while read -r item; do
ls firmwares/zephyr-${variant}.* >> ${TEMP_LIST}
done
cat ${TEMP_LIST}
tar -cjhf ${PACKAGE}-${VERSION}.tar.bz2 -X extra/package_core.exc -T ${TEMP_LIST} --transform "s,^,${PACKAGE}/,"
mkdir -p distrib
tar -cjhf distrib/${PACKAGE}-${VERSION}.tar.bz2 -X extra/package_core.exc -T ${TEMP_LIST} --transform "s,^,${PACKAGE}/,"
rm -f ${TEMP_LIST}
75 changes: 75 additions & 0 deletions extra/package_tool.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

set -e

TOOL_NAME=$(basename $1)
VERSION=$2

BASE_DIR=$(readlink -f $(dirname $0)/..)
TOOL_DIR="$BASE_DIR/extra/$TOOL_NAME"
if ! [ -d "$TOOL_DIR" ] || [ -z "$VERSION" ] ; then
echo "Usage: $0 <tool_name> <version>"
exit 1
fi

DIR=${BASE_DIR}/distrib

hash_file() {
plat=$1
file=$2
name=$(basename $file)
hash=$(sha256sum $file | cut -d ' ' -f 1)
len=$(stat -c %s $file)
cat << EOF
{
"host": "$plat",
"url": "https://downloads.arduino.cc/tools/$name",
"archiveFileName": "$name",
"checksum": "SHA-256:$hash",
"size": "$len"
}
EOF
}

build_for_arch() {
local os=$1
local arch=$2
local plat=$3

if [ "$os" == "windows" ]; then
app_ext=".exe"
pkg_ext=".zip"
pkg_cmd="zip -qr"
else
app_ext=""
pkg_ext=".tar.gz"
pkg_cmd="tar -czf"
fi

local tool_stem="$DIR/$TOOL_NAME-$VERSION"
local build_dir="$tool_stem/$plat"
local build_file="$TOOL_NAME$app_ext"
local package_file="$tool_stem-$plat$pkg_ext"

echo "Building $TOOL_NAME for $os/$arch ($plat)"
mkdir -p "$build_dir"
(cd $BASE_DIR/extra/$TOOL_NAME && GOOS="$os" GOARCH="$arch" go build -o "$build_dir/$build_file")
(cd "$tool_stem" && $pkg_cmd "$package_file" $plat/)
hash_file $plat "$package_file" > $build_dir.json
}

build_json() {
temp_file=$(mktemp)
echo "{ \"packages\": [ { \"tools\": [ { \"name\": \"$TOOL_NAME\", \"version\": \"$VERSION\", \"systems\":" > $temp_file
ls $DIR/$TOOL_NAME-$VERSION/*.json | sort | xargs cat | jq -s . >> $temp_file
echo "} ] } ] }" >> $temp_file
jq . $temp_file > $DIR/$TOOL_NAME-$VERSION.json
rm -f $temp_file $DIR/$TOOL_NAME-$VERSION/*.json
}

build_for_arch "linux" "amd64" "x86_64-linux-gnu"
build_for_arch "linux" "arm64" "aarch64-linux-gnu"
build_for_arch "darwin" "amd64" "i386-apple-darwin11"
build_for_arch "windows" "386" "i686-mingw32"
build_json
echo "Build completed for $TOOL_NAME $VERSION: $DIR/$TOOL_NAME-$VERSION.json"
20 changes: 0 additions & 20 deletions extra/zephyr-sketch-tool/build.sh

This file was deleted.