<commit_before>#!/bin/sh -eu

set -eu -o pipefail

git clone file://$PWD/downloads downloads-output

cd bosh-release-compiler

source bin/target-bosh-director ../bosh-director

tar -xzf ../release/*.tgz $( tar -tzf ../release/*.tgz | grep release.MF$ )
release_name=$( grep '^name:' release.MF | awk '{print $2}' | tr -d "\"'" )
release_version=$( grep '^version:' release.MF | awk '{print $2}' | tr -d "\"'" )

tar -xzf ../stemcell/*.tgz stemcell.MF
stemcell_name=$( grep '^name:' stemcell.MF | awk '{print $2}' | tr -d "\"'" )
stemcell_os=$( grep '^operating_system:' stemcell.MF | awk '{print $2}' | tr -d "\"'" )
stemcell_version=$( grep '^version:' stemcell.MF | awk '{print $2}' | tr -d "\"'" )

export BOSH_DEPLOYMENT="$release_name-$release_version-on-$stemcell_os-stemcell-$stemcell_version"

bosh upload-stemcell ../stemcell/*.tgz
bosh upload-release ../release/*.tgz

cat > deployment.yml <<EOF
name: "$BOSH_DEPLOYMENT"
instance_groups: []
releases:
  - name: "$release_name"
    version: "$release_version"
stemcells:
  - alias: "default"
    name: "$stemcell_name"
    version: "$stemcell_version"
update:
  canaries: 1
  canary_watch_time: 1
  max_in_flight: 1
  update_watch_time: 1
EOF

bosh -n deploy deployment.yml

bosh export-release "$release_name/$release_version" "$stemcell_os/$stemcell_version"

fullname="$BOSH_DEPLOYMENT-compiled-1.$( date -u +%Y%m%d%H%M%S ).0.tgz"
mv *.tgz ../compiled-release/$BOSH_DEPLOYMENT.tgz

jq -n \
  --arg version "$release_version" \
  --arg download_prefix "$download_prefix" \
  --arg stemcell_os "$stemcell_os" \
  --arg stemcell_version "$stemcell_version" \
  --arg fullname "$fullname" \
  '
    {
      "metadata": [
        {
          "key": "stability",
          "value": "stable",
        },
        {
          "key": "type",
          "value": "bosh-compiled-release"
        },
        {
          "key": "stemcell_os",
          "value": $stemcell_os
        },
        {
          "key": "stemcell_version",
          "value": $stemcell_version
        },
        {
          "key": "version",
          "value": $version
        }
      ],
      "origin": [
        {
          "uri": "\($download_prefix)\($fullname)"
        }
      ]
    }
  ' \
  | ./bin/commit-download ../compiled-release/$BOSH_DEPLOYMENT.tgz ../downloads-output

mv ../compiled-release/$BOSH_DEPLOYMENT.tgz ../compiled-release/$fullname<commit_msg>always commit full name download receipts<commit_after>#!/bin/sh

set -eu -o pipefail

git clone file://$PWD/downloads downloads-output

cd bosh-release-compiler

source bin/target-bosh-director ../bosh-director

tar -xzf ../release/*.tgz $( tar -tzf ../release/*.tgz | grep release.MF$ )
release_name=$( grep '^name:' release.MF | awk '{print $2}' | tr -d "\"'" )
release_version=$( grep '^version:' release.MF | awk '{print $2}' | tr -d "\"'" )

tar -xzf ../stemcell/*.tgz stemcell.MF
stemcell_name=$( grep '^name:' stemcell.MF | awk '{print $2}' | tr -d "\"'" )
stemcell_os=$( grep '^operating_system:' stemcell.MF | awk '{print $2}' | tr -d "\"'" )
stemcell_version=$( grep '^version:' stemcell.MF | awk '{print $2}' | tr -d "\"'" )

export BOSH_DEPLOYMENT="$release_name-$release_version-on-$stemcell_os-stemcell-$stemcell_version"

bosh upload-stemcell ../stemcell/*.tgz
bosh upload-release ../release/*.tgz

cat > deployment.yml <<EOF
name: "$BOSH_DEPLOYMENT"
instance_groups: []
releases:
  - name: "$release_name"
    version: "$release_version"
stemcells:
  - alias: "default"
    name: "$stemcell_name"
    version: "$stemcell_version"
update:
  canaries: 1
  canary_watch_time: 1
  max_in_flight: 1
  update_watch_time: 1
EOF

bosh -n deploy deployment.yml

bosh export-release "$release_name/$release_version" "$stemcell_os/$stemcell_version"

fullname="$BOSH_DEPLOYMENT-compiled-1.$( date -u +%Y%m%d%H%M%S ).0.tgz"
mv *.tgz ../compiled-release/$fullname

jq -n \
  --arg version "$release_version" \
  --arg download_prefix "$download_prefix" \
  --arg stemcell_os "$stemcell_os" \
  --arg stemcell_version "$stemcell_version" \
  --arg fullname "$fullname" \
  '
    {
      "metadata": [
        {
          "key": "stability",
          "value": "stable",
        },
        {
          "key": "type",
          "value": "bosh-compiled-release"
        },
        {
          "key": "stemcell_os",
          "value": $stemcell_os
        },
        {
          "key": "stemcell_version",
          "value": $stemcell_version
        },
        {
          "key": "version",
          "value": $version
        }
      ],
      "origin": [
        {
          "uri": "\($download_prefix)\($fullname)"
        }
      ]
    }
  ' \
  | ./bin/commit-download ../compiled-release/$fullname ../downloads-output
{'fraction_non_alphanumeric': 0.17935128259486963, 'fraction_numerical': 0.004663981344074624, 'mean_word_length': 2.6376252891287586, 'pattern_counts': {'":': 26, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2340328', 'n_tokens_mistral': 1781, 'n_tokens_neox': 1634, 'n_words': 342}