Skip to content

Commit e90f27e

Browse files
Release task
1 parent e890c56 commit e90f27e

File tree

4 files changed

+202
-50
lines changed

4 files changed

+202
-50
lines changed

Taskfile.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Task tool documentation:
2+
# 1) Basics: https://taskfile.dev/usage
3+
# 2) Naming conventions: https://taskfile.dev/styleguide
4+
5+
version: '3'
6+
7+
env:
8+
AEM_ENV: '{{.AEM_ENV | default "local"}}'
9+
AEM_INSTANCE_PROCESSING_MODE: auto
10+
AEM_OUTPUT_VALUE: NONE
11+
JAVA_HOME:
12+
sh: sh aemw vendor list --output-value javaHome
13+
14+
dotenv:
15+
- '.env' # VCS-ignored, user-specific
16+
- '.env.{{.AEM_ENV}}' # VCS-ignored, env-specific
17+
- '{{.AEM_ENV}}.env' # VCS-tracked, env-specific
18+
19+
tasks:
20+
21+
release:
22+
desc: Release a new version
23+
vars:
24+
VERSION: ""
25+
cmds:
26+
- |
27+
set -e
28+
29+
VERSION="{{.CLI_ARGS | default ""}}"
30+
VERSION_TAG="v$VERSION"
31+
32+
VERSION_CURRENT_TAG=$(git describe --tags --abbrev=0 || echo "v0.0.0")
33+
VERSION_CURRENT_TAG="${VERSION_CURRENT_TAG#v}" # remove leading 'v', preserve leading zeros
34+
35+
if [ -z "$VERSION" ]; then
36+
echo "Release version is not specified!"
37+
echo "Last released: ${VERSION_CURRENT_TAG}"
38+
exit 1
39+
fi
40+
41+
GIT_STAT=$(git diff --stat || true)
42+
43+
if [ "$GIT_STAT" != '' ]; then
44+
echo "Unable to release. Uncommitted changes detected!"
45+
exit 1
46+
fi
47+
48+
echo ""
49+
echo "Releasing $VERSION_TAG"
50+
echo ""
51+
52+
echo "Bumping version in files"
53+
bump_version() {
54+
local file="$1"
55+
if [ "$(uname)" = "Darwin" ]; then
56+
sed -i '' 's/AEM_CLI_VERSION:-"[^\"]*"/AEM_CLI_VERSION:-"'"$VERSION"'"/g' "$file"
57+
# shellcheck disable=SC2016
58+
sed -i '' 's/aem\@v[^\`]*\`/aem@v'"$VERSION"\`'/g' "$file"
59+
else
60+
sed -i 's/AEM_CLI_VERSION:-"[^\"]*"/AEM_CLI_VERSION:-"'"$VERSION"'"/g' "$file"
61+
# shellcheck disable=SC2016
62+
sed -i 's/aem\@v[^\`]*\`/aem@v'"$VERSION"\`'/g' "$file"
63+
fi
64+
}
65+
bump_version "README.MD"
66+
bump_version "pkg/project/common/aemw"
67+
68+
echo "Pushing version bump"
69+
git commit -a -m "Release $VERSION_TAG" || echo "No changes to commit"
70+
git push || echo "Nothing to push"
71+
72+
echo "Pushing release tag '$VERSION_TAG'"
73+
git tag "$VERSION_TAG"
74+
git push origin "$VERSION_TAG" || echo "Tag already exists or cannot push"

release-snapshot.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

release.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

taskw

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/usr/bin/env sh
2+
3+
VERSION=${TASK_VERSION:-"3.40.0"}
4+
5+
# Define API
6+
# ==========
7+
8+
# https://github.com/client9/shlib/blob/master/uname_os.sh
9+
detect_os() {
10+
os=$(uname -s | tr '[:upper:]' '[:lower:]')
11+
12+
# fixed up for https://git hub.com/client9/shlib/issues/3
13+
case "$os" in
14+
msys*) os="windows" ;;
15+
mingw*) os="windows" ;;
16+
cygwin*) os="windows" ;;
17+
win*) os="windows" ;; # for windows busybox and like # https://frippery.org/busybox/
18+
esac
19+
20+
# other fixups here
21+
echo "$os"
22+
}
23+
24+
# https://github.com/client9/shlib/blob/master/uname_arch.sh
25+
detect_arch() {
26+
arch=$(uname -m)
27+
case $arch in
28+
x86_64) arch="amd64" ;;
29+
x86) arch="386" ;;
30+
i686) arch="386" ;;
31+
i386) arch="386" ;;
32+
aarch64) arch="arm64" ;;
33+
armv5*) arch="armv5" ;;
34+
armv6*) arch="armv6" ;;
35+
armv7*) arch="armv7" ;;
36+
esac
37+
echo ${arch}
38+
}
39+
40+
# https://github.com/client9/shlib/blob/master/http_download.sh
41+
download_file() {
42+
local_file=$1
43+
source_url=$2
44+
header=$3
45+
if [ -z "$header" ]; then
46+
code=$(curl -w '%{http_code}' -sL -o "$local_file" "$source_url")
47+
else
48+
code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
49+
fi
50+
if [ "$code" != "200" ]; then
51+
echo "Error! Downloading file from URL '$source_url' received HTTP status '$code'"
52+
return 1
53+
fi
54+
return 0
55+
}
56+
57+
download_file_once () {
58+
URL=$1
59+
FILE=$2
60+
if [ ! -f "${FILE}" ]; then
61+
mkdir -p "$(dirname "$FILE")"
62+
FILE_TMP="$2.tmp"
63+
download_file "$FILE_TMP" "$URL"
64+
mv "$FILE_TMP" "$FILE"
65+
fi
66+
}
67+
68+
unarchive_file() {
69+
FILE=$1
70+
DIR=$2
71+
72+
rm -fr "$DIR"
73+
mkdir -p "$DIR"
74+
if [ "${FILE##*.}" = "zip" ] ; then
75+
unzip "$FILE" -d "$DIR"
76+
else
77+
tar -xf "$FILE" -C "$DIR"
78+
fi
79+
}
80+
81+
82+
# Download tool
83+
# =============
84+
85+
OS=$(detect_os)
86+
ARCH=$(detect_arch)
87+
88+
AEM_DIR="aem"
89+
HOME_DIR="${AEM_DIR}/home"
90+
DOWNLOAD_DIR="${HOME_DIR}/opt"
91+
92+
BIN_DOWNLOAD_NAME="task"
93+
BIN_ARCHIVE_EXT="tar.gz"
94+
if [ "$OS" = "windows" ] ; then
95+
BIN_ARCHIVE_EXT="zip"
96+
fi
97+
BIN_DOWNLOAD_URL="https://github.com/go-task/task/releases/download/v${VERSION}/${BIN_DOWNLOAD_NAME}_${OS}_${ARCH}.${BIN_ARCHIVE_EXT}"
98+
BIN_ROOT="${DOWNLOAD_DIR}/${BIN_DOWNLOAD_NAME}/${VERSION}"
99+
BIN_ARCHIVE_FILE="${BIN_ROOT}/${BIN_DOWNLOAD_NAME}.${BIN_ARCHIVE_EXT}"
100+
BIN_ARCHIVE_DIR="${BIN_ROOT}/${BIN_DOWNLOAD_NAME}"
101+
BIN_NAME="task"
102+
BIN_EXEC_FILE="${BIN_ARCHIVE_DIR}/${BIN_NAME}"
103+
104+
if [ ! -f "${BIN_EXEC_FILE}" ]; then
105+
mkdir -p "${BIN_ARCHIVE_DIR}"
106+
download_file_once "${BIN_DOWNLOAD_URL}" "${BIN_ARCHIVE_FILE}"
107+
unarchive_file "${BIN_ARCHIVE_FILE}" "${BIN_ARCHIVE_DIR}"
108+
chmod +x "${BIN_EXEC_FILE}"
109+
fi
110+
111+
# Prevent OS or shell-specific glitches
112+
# =====================================
113+
114+
# https://stackoverflow.com/questions/7250130/how-to-stop-mingw-and-msys-from-mangling-path-names-given-at-the-command-line
115+
export MSYS_NO_PATHCONV=1
116+
export MSYS2_ARG_CONV_EXCL="*"
117+
export MSYS2_ENV_CONV_EXCL="*"
118+
119+
# Execute Task Tool
120+
# =================
121+
122+
# https://taskfile.dev/api/#env
123+
export TASK_COLOR_GREEN=35
124+
125+
# https://taskfile.dev/experiments/env-precedence
126+
export TASK_X_ENV_PRECEDENCE=1
127+
128+
"./${BIN_EXEC_FILE}" "$@"

0 commit comments

Comments
 (0)