diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a541e74..e9675b2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,9 +1,9 @@ -name: "Release" +name: Release on: + workflow_dispatch: push: branches: - main - workflow_dispatch: jobs: deploy: @@ -19,20 +19,17 @@ jobs: - name: Publish Feature uses: devcontainers/action@v1 with: - base-path-to-features: "./src" - publish-features: "true" - features-namespace: "alertbox/oven-sh" - generate-docs: "true" - disable-repo-tagging: "true" - + base-path-to-features: ./src + publish-features: true + features-namespace: alertbox/oven-sh + generate-docs: true + disable-repo-tagging: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create PR for Docs - env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | set -e @@ -41,17 +38,17 @@ jobs: git config --global user.name github-actions git config pull.rebase false - branch=automated-documentation-update-$GITHUB_RUN_ID - git checkout -b $branch + branch="automated-documentation-update-$GITHUB_RUN_ID" + git checkout -b "$branch" # Add / update and commit git add */**/README.md git commit -m 'docs: recreate feature README.md [skip ci]' || export NO_UPDATES=true # Push - if [ "$NO_UPDATES" != "true" ] ; then - message='docs: recreate feature README.md' - description='this changeset is auto-generated via github workflow.' - git push origin "$branch" - gh pr create --title "$message" --body "$description" + if [ "$NO_UPDATES" != "true" ]; then + message='docs: recreate feature README.md' + description='this changeset is auto-generated via github workflow.' + git push origin "$branch" + gh pr create --title "$message" --body "$description" fi diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yaml similarity index 55% rename from .github/workflows/validate.yml rename to .github/workflows/validate.yaml index cd6b342..86329fd 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yaml @@ -1,4 +1,4 @@ -name: "Validate" +name: Validate on: pull_request: workflow_dispatch: @@ -12,13 +12,13 @@ jobs: - name: Validate Configurations uses: devcontainers/action@v1 with: - validate-only: "true" - base-path-to-features: "./src" + validate-only: true + base-path-to-features: ./src - name: Lint Shell Scripts uses: azohra/shell-linter@v0.6.0 with: - path: "src/**/*.sh" - severity: "error" # [style, info, warning, error] + path: src/**/*.sh + severity: error # [style, info, warning, error] env: - SHELLCHECK_OPTS: -e SC2072 # Acceptable use of decimal comparison + SHELLCHECK_OPTS: -e SC2072 # Acceptable use of decimal comparison diff --git a/src/bun/devcontainer-feature.json b/src/bun/devcontainer-feature.json index 2500312..a480c99 100644 --- a/src/bun/devcontainer-feature.json +++ b/src/bun/devcontainer-feature.json @@ -17,7 +17,7 @@ "type": "string", "default": "", "description": "Optional list of Node.js-compatible packages to install system-wide." - }, + } }, "customizations": { "vscode": { diff --git a/src/bun/install.sh b/src/bun/install.sh index ac42801..23edce8 100644 --- a/src/bun/install.sh +++ b/src/bun/install.sh @@ -3,8 +3,10 @@ # The 'install.sh' entrypoint script is always executed as the root user. # # This script installs Bun CLI. -# Source: https://bun.sh/install -# https://github.com/oven-sh/bun/tree/main/dockerhub +# +# Sources: +# - https://bun.sh/install +# - https://github.com/oven-sh/bun/tree/main/dockerhub set -e @@ -22,36 +24,56 @@ check_packages() { export DEBIAN_FRONTEND=noninteractive -# https://github.com/oven-sh/bun/releases -VERSION=${VERSION:-"latest"} -# https://bun.sh/docs/cli/add -PACKAGES=${PACKAGES:-} +# See https://github.com/oven-sh/bun/releases +VERSION="${VERSION:-latest}" + +# See https://bun.sh/docs/cli/add +PACKAGES="${PACKAGES:-}" echo "Activating feature 'bun'" -# Clean up. +# Clean up rm -rf /var/lib/apt/lists/* +# Install required dependencies check_packages ca-certificates curl dirmngr gpg gpg-agent unzip ARCH="$(dpkg --print-architecture)" case "${ARCH##*-}" in - amd64) BUILD="x64-baseline";; - arm64) BUILD="aarch64";; - *) echo "error: unsupported architecture: $ARCH"; exit 1 ;; + amd64) + BUILD="x64-baseline" + ;; + arm64) + BUILD="aarch64" + ;; + *) + echo "error: unsupported architecture: ${ARCH}" + exit 1 + ;; esac case "${VERSION}" in - latest | canary | bun-v*) TAG="$VERSION"; ;; - v*) TAG="bun-${VERSION}"; ;; - *) TAG="bun-v${VERSION}"; ;; + latest | canary | bun-v*) + TAG="${VERSION}" + ;; + v*) + TAG="bun-${VERSION}" + ;; + *) + TAG="bun-v${VERSION}" + ;; esac case "${TAG}" in - latest) RELEASE="latest/download"; ;; - *) RELEASE="download/${TAG}"; ;; + latest) + RELEASE="latest/download" + ;; + *) + RELEASE="download/${TAG}" + ;; esac +# Setup environment variables and paths INSTALL_ENV="BUN_INSTALL" BIN_ENV="\$${INSTALL_ENV}/bin" @@ -60,22 +82,32 @@ BIN_DIR="${INSTALL_DIR}/bin" EXE="${BIN_DIR}/bun" ZIP="bun-linux-${BUILD}.zip" -curl "https://github.com/oven-sh/bun/releases/${RELEASE}/${ZIP}" -fsSLO --compressed --retry 5 || - (echo "error: failed to download: ${TAG}" && exit 1) +curl "https://github.com/oven-sh/bun/releases/${RELEASE}/${ZIP}" -fsSLO --compressed --retry 5 || { + echo "error: failed to download: ${TAG}" + exit 1 +} -unzip $ZIP || - (echo "error: failed to unzip ${ZIP}." && exit 1) +unzip "${ZIP}" || { + echo "error: failed to unzip ${ZIP}." + exit 1 +} -if [[ ! -d $BIN_DIR ]]; then - mkdir -p $BIN_DIR || - (echo "error: failed to create install directory ${BIN_DIR}." && exit 1) +if [[ ! -d "${BIN_DIR}" ]]; then + mkdir -p "${BIN_DIR}" || { + echo "error: failed to create install directory ${BIN_DIR}." + exit 1 + } fi -mv "bun-linux-${BUILD}/bun" $EXE || - (echo "error: failed to move extracted bun to destination." && exit 1) +mv "bun-linux-${BUILD}/bun" "${EXE}" || { + echo "error: failed to move extracted bun to destination." + exit 1 +} -chmod +x $EXE || - (echo "error: failed to set permission on bun executable." && exit 1) +chmod +x "${EXE}" || { + echo "error: failed to set permission on bun executable." + exit 1 +} commands=( "export ${INSTALL_ENV}=\"${INSTALL_DIR}\"" @@ -87,7 +119,7 @@ bash_configs=( "${_REMOTE_USER_HOME}/.bash_profile" ) -if [[ ${XDG_CONFIG_HOME:-} ]]; then +if [[ -n "${XDG_CONFIG_HOME:-}" ]]; then bash_configs+=( "${XDG_CONFIG_HOME}/.bash_profile" "${XDG_CONFIG_HOME}/.bashrc" @@ -97,23 +129,23 @@ if [[ ${XDG_CONFIG_HOME:-} ]]; then fi for bash_config in "${bash_configs[@]}"; do - if [[ -w $bash_config ]]; then + if [[ -w "${bash_config}" ]]; then { echo -e '\n# bun' for command in "${commands[@]}"; do - echo "$command" + echo "${command}" done - } >> "$bash_config" + } >> "${bash_config}" break fi done # If packages are requested, install globally. # Ensure `bun install -g` works. -if [ ${#PACKAGES[@]} -gt 0 ]; then - su ${_REMOTE_USER} -c "$EXE add --global $PACKAGES" +if [ "${#PACKAGES[@]}" -gt 0 ]; then + su "${_REMOTE_USER}" -c "${EXE} add --global ${PACKAGES}" fi -rm -rf $ZIP +rm -rf "${ZIP}" echo "Done!"