Skip to content
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

[v3] Prepare for v3 #283

Merged
merged 27 commits into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c743d7c
Add docs/reference split
ErikSchierboom Feb 26, 2020
6dffe46
Fix exercise directory structure
ErikSchierboom Jun 24, 2020
ec44932
Add stubs for concept documents
ErikSchierboom Oct 14, 2020
9598114
Add concept headings to introduction.md
ErikSchierboom Nov 10, 2020
7043fd4
Format code
SaschaMann Nov 24, 2020
995389c
Cleanup instructions headings
ErikSchierboom Jan 12, 2021
78a0f81
Add concept introductions
ErikSchierboom Jan 12, 2021
f24255f
[v3] Move existing exercises to exercises/practice
ErikSchierboom Jan 29, 2021
4a55381
[v3] Add version property to config.json
ErikSchierboom Jan 29, 2021
39956c6
[v3] Add status to config.json
ErikSchierboom Jan 29, 2021
b216510
[v3] Add slug to config.json
ErikSchierboom Jan 29, 2021
7347f29
[v3] Add online_editor property to config.json
ErikSchierboom Jan 29, 2021
56022f5
[v3] Re-order practice exercises in config.json
ErikSchierboom Jan 29, 2021
8e2a345
[v3] Remove deprecated properties from practice exercises in config.json
ErikSchierboom Jan 29, 2021
e7d63f7
[v3] Add name property to practice exercises in config.json
ErikSchierboom Jan 29, 2021
70cab91
[v3] Add (empty) prerequisites property to practice exercises in conf…
ErikSchierboom Jan 29, 2021
9e9be3d
[v3] Move exercises to practice exercises property in config.json
ErikSchierboom Jan 29, 2021
fd49dc8
[v3] Add concept exercises to config.json
ErikSchierboom Jan 29, 2021
2c5468c
[v3] Add wip status to concept exercises in config.json
ErikSchierboom Jan 29, 2021
bc8c7ec
[v3] Add concepts to config.json
ErikSchierboom Jan 29, 2021
d8f71d9
[v3] Add key features to config.json
ErikSchierboom Jan 29, 2021
1f46db4
[v3] Add tags to config.json
ErikSchierboom Jan 29, 2021
77fee12
[v3] Add configlet CI workflow
ErikSchierboom Jan 29, 2021
cb45590
[v3] Update fetch-configlet script to work with configlet v3
ErikSchierboom Jan 29, 2021
a053e31
[v3] Add dependabot to keep GHA dependencies up-to-date
ErikSchierboom Jan 29, 2021
38f212f
[v3] Convert relative v3 links to absolute links
ErikSchierboom Jan 29, 2021
8b0950f
[v3] Fix configlet CI workflow
ErikSchierboom Jan 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[v3] Update fetch-configlet script to work with configlet v3
  • Loading branch information
ErikSchierboom committed Jan 29, 2021
commit cb45590301dc982ab404694ce84d9b4dda7e549d
68 changes: 37 additions & 31 deletions bin/fetch-configlet
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,54 @@ set -eo pipefail
readonly LATEST='https://api.github.com/repos/exercism/configlet/releases/latest'

case "$(uname)" in
(Darwin*) OS='mac' ;;
(Linux*) OS='linux' ;;
(Windows*) OS='windows' ;;
(MINGW*) OS='windows' ;;
(MSYS_NT-*) OS='windows' ;;
(*) OS='linux' ;;
Darwin*) os='mac' ;;
Linux*) os='linux' ;;
Windows*) os='windows' ;;
MINGW*) os='windows' ;;
MSYS_NT-*) os='windows' ;;
*) os='linux' ;;
esac

case "$OS" in
(windows*) EXT='zip' ;;
(*) EXT='tgz' ;;
case "${os}" in
windows*) ext='zip' ;;
*) ext='tgz' ;;
esac

case "$(uname -m)" in
(*64*) ARCH='64bit' ;;
(*686*) ARCH='32bit' ;;
(*386*) ARCH='32bit' ;;
(*) ARCH='64bit' ;;
*64*) arch='64bit' ;;
*686*) arch='32bit' ;;
*386*) arch='32bit' ;;
*) arch='64bit' ;;
esac

if [ -z "${GITHUB_TOKEN}" ]
then
HEADER=''
else
HEADER="authorization: Bearer ${GITHUB_TOKEN}"
curlopts=(
--silent
--show-error
--fail
--location
--retry 3
)

if [[ -n "${GITHUB_TOKEN}" ]]; then
curlopts+=(--header "authorization: Bearer ${GITHUB_TOKEN}")
fi

FILENAME="configlet-${OS}-${ARCH}.${EXT}"
suffix="${os}-${arch}.${ext}"

get_url () {
curl --header "$HEADER" -s "$LATEST" |
awk -v filename=$FILENAME '$1 ~ /browser_download_url/ && $2 ~ filename { print $2 }' |
tr -d '"'
get_download_url() {
curl "${curlopts[@]}" --header 'Accept: application/vnd.github.v3+json' "${LATEST}" |
grep "\"browser_download_url\": \".*/download/.*/configlet.*${suffix}\"$" |
cut -d'"' -f4
}

URL=$(get_url)
download_url="$(get_download_url)"
output_dir="bin"
output_path="${output_dir}/latest-configlet.${ext}"
curl "${curlopts[@]}" --output "${output_path}" "${download_url}"

case "$EXT" in
(*zip)
curl --header "$HEADER" -s --location "$URL" -o bin/latest-configlet.zip
unzip bin/latest-configlet.zip -d bin/
rm bin/latest-configlet.zip
;;
(*) curl --header "$HEADER" -s --location "$URL" | tar xz -C bin/ ;;
case "${ext}" in
*zip) unzip "${output_path}" -d "${output_dir}" ;;
*) tar xzf "${output_path}" -C "${output_dir}" ;;
esac

rm -f "${output_path}"
32 changes: 17 additions & 15 deletions bin/fetch-configlet.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
Function DownloadUrl ([string] $FileName, $Headers) {
$latestUrl = "https://api.github.com/repos/exercism/configlet/releases/latest"
$json = Invoke-RestMethod -Headers $Headers -Uri $latestUrl
$json.assets | Where-Object { $_.browser_download_url -match $FileName } | Select-Object -ExpandProperty browser_download_url
}
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"

Function Headers {
If ($GITHUB_TOKEN) { @{ Authorization = "Bearer ${GITHUB_TOKEN}" } } Else { @{ } }
$requestOpts = @{
Headers = If ($env:GITHUB_TOKEN) { @{ Authorization = "Bearer ${env:GITHUB_TOKEN}" } } Else { @{ } }
MaximumRetryCount = 3
RetryIntervalSec = 1
}

Function Arch {
If ([Environment]::Is64BitOperatingSystem) { "64bit" } Else { "32bit" }
$arch = If ([Environment]::Is64BitOperatingSystem) { "64bit" } Else { "32bit" }
$fileName = "configlet-windows-$arch.zip"

Function Get-DownloadUrl {
$latestUrl = "https://api.github.com/repos/exercism/configlet/releases/latest"
Invoke-RestMethod -Uri $latestUrl -PreserveAuthorizationOnRedirect @requestOpts
| Select-Object -ExpandProperty assets
| Where-Object { $_.browser_download_url -match $FileName }
| Select-Object -ExpandProperty browser_download_url
}

$arch = Arch
$headers = Headers
$fileName = "configlet-windows-$arch.zip"
$downloadUrl = Get-DownloadUrl
$outputDirectory = "bin"
$outputFile = Join-Path -Path $outputDirectory -ChildPath $fileName
$zipUrl = DownloadUrl -FileName $fileName -Headers $headers

Invoke-WebRequest -Headers $headers -Uri $zipUrl -OutFile $outputFile
Invoke-WebRequest -Uri $downloadUrl -OutFile $outputFile @requestOpts
Expand-Archive $outputFile -DestinationPath $outputDirectory -Force
Remove-Item -Path $outputFile