<commit_before>#!/usr/bin/env bash

# Upload files to a GitHub release
#
#    upload-release.sh <path> <asset> <triple> <label>
#
# <path> is the local path to the binary, <asset> is (usually) the binary name, <triple> is the target triple
# (see https://github.com/japaric/trust#supported-targets) and <label> is the label for the
# file on the GitHub release page.
#
#    upload-release.sh ./target/release/stencila stencila x86_64-unknown-linux-gnu Linux%20CLI
#
# Expects the $GITHUB_TOKEN to be set and for the release for the current tag to have already
# been created.

set -e

FILE_PATH=$1
ASSET_NAME=$2
TARGET_TRIPLE=$3
DOWNLOAD_LABEL=$4

AUTH_HEADER="Authorization: token $GITHUB_TOKEN"
TAG=$(git describe --tags --abbrev=0)
echo "Will upload for tag $TAG"
RELEASE_ID=$(curl -s -H "$AUTH_HEADER" "https://api.github.com/repos/stencila/stencila/releases/tags/$TAG" | sed -n 's/^  "id": \(\S*\),$/\1/p')
echo "Will upload to release $RELEASE_ID"
DOWNLOAD_NAME="$ASSET_NAME-$TAG-$TARGET_TRIPLE"
UPLOAD_URL="https://uploads.github.com/repos/stencila/stencila/releases/$RELEASE_ID/assets?name=$DOWNLOAD_NAME&label=$DOWNLOAD_LABEL"
echo "Will upload $FILE_PATH to $UPLOAD_URL"
curl -H "$AUTH_HEADER" -H "Content-Type: application/octet-stream" -o /dev/null --data-binary @"$FILE_PATH" "$UPLOAD_URL"
echo "Upload complete"<commit_msg>fix(Release): Avoid sed which differs on MacOS<commit_after>#!/usr/bin/env bash

# Upload files to a GitHub release
#
#    upload-release.sh <path> <asset> <triple> <label>
#
# <path> is the local path to the binary, <asset> is (usually) the binary name, <triple> is the target triple
# (see https://github.com/japaric/trust#supported-targets) and <label> is the label for the
# file on the GitHub release page.
#
#    upload-release.sh ./target/release/stencila stencila x86_64-unknown-linux-gnu Linux%20CLI
#
# Expects the $GITHUB_TOKEN to be set and for the release for the current tag to have already
# been created.

set -e

FILE_PATH=$1
ASSET_NAME=$2
TARGET_TRIPLE=$3
DOWNLOAD_LABEL=$4

AUTH_HEADER="Authorization: token $GITHUB_TOKEN"
TAG=$(git describe --tags --abbrev=0)
echo "Will upload for tag $TAG"
RELEASE_ID=$(curl -s -H "$AUTH_HEADER" "https://api.github.com/repos/stencila/stencila/releases/tags/$TAG" | grep -m 1 "id.:" | cut -c9-16)
echo "Will upload to release $RELEASE_ID"
DOWNLOAD_NAME="$ASSET_NAME-$TAG-$TARGET_TRIPLE"
UPLOAD_URL="https://uploads.github.com/repos/stencila/stencila/releases/$RELEASE_ID/assets?name=$DOWNLOAD_NAME&label=$DOWNLOAD_LABEL"
echo "Will upload $FILE_PATH to $UPLOAD_URL"
curl -H "$AUTH_HEADER" -H "Content-Type: application/octet-stream" -o /dev/null --data-binary @"$FILE_PATH" "$UPLOAD_URL"
echo "Upload complete"
{'fraction_non_alphanumeric': 0.14211695040710584, 'fraction_numerical': 0.00999259807549963, 'mean_word_length': 5.060538116591928, 'pattern_counts': {'":': 1, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4293084', 'n_tokens_mistral': 997, 'n_tokens_neox': 965, 'n_words': 262}