Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 14 additions & 17 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "Release"
name: Release
on:
workflow_dispatch:
push:
branches:
- main
workflow_dispatch:

jobs:
deploy:
Expand All @@ -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

Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Validate"
name: Validate
on:
pull_request:
workflow_dispatch:
Expand All @@ -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/[email protected]
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
2 changes: 1 addition & 1 deletion src/bun/devcontainer-feature.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"type": "string",
"default": "",
"description": "Optional list of Node.js-compatible packages to install system-wide."
},
}
},
"customizations": {
"vscode": {
Expand Down
98 changes: 65 additions & 33 deletions src/bun/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"

Expand All @@ -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}\""
Expand All @@ -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"
Expand All @@ -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!"