Skip to content

Commit

Permalink
Added basic support for DevContainer feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Kralizek committed Mar 6, 2023
1 parent e38cf54 commit f0a9804
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ permissions:
jobs:

prepare:
name: Preparation
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -112,3 +113,23 @@ jobs:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
dotnet nuget push ./outputs/packages/*.nupkg --api-key $NUGET_AUTH_TOKEN --source https://nuget.pkg.github.com/Kralizek/index.json --skip-duplicate
feature:
name: DevContainer feature
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.3.0

- name: Get tag name
id: get_tag_name
run: echo "::set-output name=tag::$(echo "${{ github.ref }}" | grep -oP 'refs/tags/\K(.+)')"

- name: Publish feature
uses: devcontainers/action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
base-path-to-features: './features'
publish-features: true
17 changes: 17 additions & 0 deletions features/hyde/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "hyde",
"name": "Hyde",
"description": "A tool to handle Jekyll posts and pages",
"documentationURL": "https://github.com/Kralizek/Hyde",
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
],
"options": {
"version": {
"type": "string",
"proposals": ["latest"],
"default": "latest",
"description": "Select the version of Hyde to install, if not latest."
}
}
}
62 changes: 62 additions & 0 deletions features/hyde/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

TOOL_VERSION=${VERSION:-"latest"}

set -e

find_version_from_git_tags() {
local variable_name=$1
local requested_version=${!variable_name}
if [ "${requested_version}" = "none" ]; then return; fi
local repository=$2
local prefix=${3:-"tags/v"}
local separator=${4:-"."}
local last_part_optional=${5:-"false"}
if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
local escaped_separator=${separator//./\\.}
local last_part
if [ "${last_part_optional}" = "true" ]; then
last_part="(${escaped_separator}[0-9]+)?"
else
last_part="${escaped_separator}[0-9]+"
fi
local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
else
set +e
declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
set -e
fi
fi
if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" > /dev/null 2>&1; then
echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2
exit 1
fi
echo "${variable_name}=${!variable_name}"
}

find_version_from_git_tags TOOL_VERSION https://github.com/Kralizek/Hyde

mkdir -p /tmp/hydetool
pushd /tmp/hydetool

echo "Downloading Hyde..."

wget https://github.com/Kralizek/Hyde/releases/download/v${TOOL_VERSION}/hyde-linux-x64.zip
exit_code=$?

set -e
if [ "$exit_code" != "0" ]; then
echo "(!) hyde version ${TOOL_VERSION} failed to download."
exit 1
fi

popd

pushd ~/.local/bin

unzip /tmp/hydetool/hyde-linux-x64.zip

rm -rf /tmp/hydetool

0 comments on commit f0a9804

Please sign in to comment.