Skip to content

Commit

Permalink
bin(upload-legacy-assets): add script (#728)
Browse files Browse the repository at this point in the history
Add a script for uploading assets that are required by old
`fetch-configlet` scripts. We can remove this script later.

See 57e6c5f (".github, fetch-configlet: rename release assets")
for context.

Track CI no longer requires the linux asset with the old name to
exist [1].

The assets in the latest release [2] at the time of writing:

    configlet-linux-64bit.tgz
    configlet-mac-64bit.tgz
    configlet-windows-64bit.zip
    configlet_4.0.0-beta.9_checksums_sha256.txt
    configlet_4.0.0-beta.9_linux_x86-64.tar.gz
    configlet_4.0.0-beta.9_macos_x86-64.tar.gz
    configlet_4.0.0-beta.9_windows_x86-64.zip

[1] exercism/github-actions@a63d5ca89437
[2] https://github.com/exercism/configlet/releases/tag/4.0.0-beta.9
  • Loading branch information
ee7 authored Mar 22, 2023
1 parent 36e6e2b commit bbbad5c
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions bin/upload-legacy-assets
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

set -eo pipefail

err() {
echo "$*" >&2
}

main() {
if [[ "$#" -eq 1 ]]; then
local tmp_dir='upload-assets-tmp'
local repo='github.com/exercism/configlet'
local tag="$1"
local arch='x86-64'
local pattern="*${arch}*"
mkdir -v -p "${tmp_dir}"
cd "${tmp_dir}"
gh -R "${repo}" release download "${tag}" -p "${pattern}"
declare -A assets=(
["configlet_${tag}_linux_${arch}.tar.gz"]='configlet-linux-64bit.tgz'
["configlet_${tag}_macos_${arch}.tar.gz"]='configlet-mac-64bit.tgz'
["configlet_${tag}_windows_${arch}.zip"]='configlet-windows-64bit.zip'
)
for k in "${!assets[@]}"; do
mv -v "${k}" "${assets[${k}]}"
done
gh -R "${repo}" release upload "${tag}" "${assets[@]}"
echo "After undrafting the new release, you can delete the assets with the old names"
echo "from the previous release"
else
err "You must call this script with exactly one argument."
err "Usage:"
err " upload-legacy-assets <tag>"
exit 1
fi
}

main "$@"

0 comments on commit bbbad5c

Please sign in to comment.