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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
uses: actions/checkout@v4

- name: Run build
run: make
run: sh taskw cli:all
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
*.so
*.dylib

# Package Files #
*.jar
*.war
*.ear

# Test binary, built with `go test -c`
*.test

Expand Down Expand Up @@ -235,4 +240,10 @@ dist/
!*.code-workspace

# Built Visual Studio Code Extensions
*.vsix
*.vsix

# AEM Compose
aem/home/
.task/
.env
.env.*
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
41 changes: 0 additions & 41 deletions Makefile

This file was deleted.

99 changes: 99 additions & 0 deletions Taskfile.aem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
version: '3'

tasks:
init:
desc: initialize project
cmds:
- sh aemw project init -V ALL

setup:
desc: start and provision AEM instances
cmds:
- task: start
- task: provision
- task: check

resetup:
desc: destroy then setup again AEM instances
cmds:
- task: destroy
- task: setup

start:
desc: start AEM instances
aliases: [ up ]
cmd: sh aemw instance launch

stop:
desc: stop AEM instances
aliases: [ down ]
cmd: sh aemw instance stop

restart:
desc: restart AEM instances
cmds:
- task: stop
- task: start

destroy:
desc: destroy AEM instances
prompt: This will permanently delete all configured AEM instances and their data. Continue?
deps: [ stop ]
cmd: sh aemw instance destroy

status:
desc: check status of AEM instances
env:
AEM_OUTPUT_VALUE: ALL
cmd: sh aemw instance status

tail:
desc: tail logs of AEM instances
cmd: tail -f aem/home/var/instance/*/crx-quickstart/logs/{stdout,error}.log

tail:author:
desc: tail logs of AEM author instance
cmd: tail -f aem/home/var/instance/author/crx-quickstart/logs/{stdout,error}.log

tail:publish:
desc: tail logs of AEM publish instance
cmd: tail -f aem/home/var/instance/publish/crx-quickstart/logs/{stdout,error}.log

provision:
desc: provision AEM instances by installing packages and applying configurations
aliases: [ configure ]
cmds:
- task: provision:repl-agent-publish
- task: provision:crx

provision:repl-agent-publish:
desc: configure replication agent on AEM author instance
internal: true
cmd: |
PROPS="
enabled: true
transportUri: {{.AEM_PUBLISH_HTTP_URL}}/bin/receive?sling:authRequestLogin=1
transportUser: {{.AEM_PUBLISH_USER}}
transportPassword: {{.AEM_PUBLISH_PASSWORD}}
userId: admin
"
echo "$PROPS" | sh aemw repl agent setup -A --location "author" --name "publish"

provision:crx:
desc: enable CRX/DE on AEM instances
internal: true
cmd: 'sh aemw osgi config save --pid "org.apache.sling.jcr.davex.impl.servlets.SlingDavExServlet" --input-string "alias: /crx/server"'

check:
deps: [ author:check, publish:check ]

author:check:
desc: check health of AEM author instance
cmds:
- curl -s -u "{{.AEM_AUTHOR_USER}}:{{.AEM_AUTHOR_PASSWORD}}" "{{.AEM_AUTHOR_HTTP_URL}}/libs/granite/core/content/login.html" | grep -q "QUICKSTART_HOMEPAGE"
- curl -s -u "{{.AEM_AUTHOR_USER}}:{{.AEM_AUTHOR_PASSWORD}}" "{{.AEM_AUTHOR_HTTP_URL}}/etc/replication/agents.author/publish.test.html" | grep -q "Replication (TEST) of /content successful"

publish:check:
desc: check health of AEM publish instance
cmd: curl -s -u "{{.AEM_PUBLISH_USER}}:{{.AEM_PUBLISH_PASSWORD}}" "{{.AEM_PUBLISH_HTTP_URL}}/libs/granite/core/content/login.html" | grep -q "QUICKSTART_HOMEPAGE"

148 changes: 148 additions & 0 deletions Taskfile.cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
version: '3'

tasks:
all:
desc: Run deps, test, vet, fmt, lint, install
cmds:
- task: deps
- task: test
- task: vet
- task: fmt
- task: lint
- task: install

deps:
desc: Install dependencies
cmds:
- go install github.com/mgechev/revive@v1.3.3
- go mod tidy

test:
desc: Run tests
cmds:
- go test ./...

test:int:
desc: Run integration tests
cmds:
- go test -tags=int_test ./...

vet:
desc: Run go vet
cmds:
- go vet ./...

fmt:
desc: Format code
cmds:
- gofmt -l -w .

lint:
desc: Run linter
cmds:
- revive -config revive.toml -formatter friendly ./...

build:
desc: Build the binary
vars:
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_COMMIT_DATE:
sh: git log -1 --date=format:'%Y-%m-%dT%H:%M:%S' --format=%cd
GIT_VERSION:
sh: git describe --tags 2>/dev/null || echo "{{.GIT_COMMIT}}"
LD_FLAGS: "-s -w -X main.appVersion={{.GIT_VERSION}} -X main.appCommit={{.GIT_COMMIT}} -X main.appCommitDate={{.GIT_COMMIT_DATE}}"
TAGS: timetzdata
cmds:
- go build -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" -o bin/aem ./cmd/aem

build:other:
desc: Build binaries for other platforms
vars:
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_COMMIT_DATE:
sh: git log -1 --date=format:'%Y-%m-%dT%H:%M:%S' --format=%cd
GIT_VERSION:
sh: git describe --tags 2>/dev/null || echo "{{.GIT_COMMIT}}"
LD_FLAGS: "-s -w -X main.appVersion={{.GIT_VERSION}} -X main.appCommit={{.GIT_COMMIT}} -X main.appCommitDate={{.GIT_COMMIT_DATE}}"
TAGS: timetzdata
cmds:
- GOARCH=amd64 GOOS=darwin go build -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" -o bin/aem.darwin ./cmd/aem
- GOARCH=amd64 GOOS=linux go build -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" -o bin/aem.linux ./cmd/aem
- GOARCH=amd64 GOOS=windows go build -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" -o bin/aem.exe ./cmd/aem

install:
desc: Install the binary
vars:
GIT_COMMIT:
sh: git rev-parse HEAD
GIT_COMMIT_DATE:
sh: git log -1 --date=format:'%Y-%m-%dT%H:%M:%S' --format=%cd
GIT_VERSION:
sh: git describe --tags 2>/dev/null || echo "{{.GIT_COMMIT}}"
LD_FLAGS: "-s -w -X main.appVersion={{.GIT_VERSION}} -X main.appCommit={{.GIT_COMMIT}} -X main.appCommitDate={{.GIT_COMMIT_DATE}}"
TAGS: timetzdata
cmds:
- go install -tags "{{.TAGS}}" --ldflags "{{.LD_FLAGS}}" ./cmd/aem

clean:
desc: Clean build artifacts
cmds:
- go clean
- rm -fr bin

release:
desc: Release a new version
vars:
VERSION: ""
cmds:
- |
set -e

VERSION="{{.CLI_ARGS | default ""}}"
VERSION_TAG="v$VERSION"

VERSION_CURRENT_TAG=$(git describe --tags --abbrev=0 || echo "v0.0.0")
VERSION_CURRENT_TAG="${VERSION_CURRENT_TAG#v}" # remove leading 'v', preserve leading zeros

if [ -z "$VERSION" ]; then
echo "Release version is not specified!"
echo "Last released: ${VERSION_CURRENT_TAG}"
exit 1
fi

GIT_STAT=$(git diff --stat || true)

if [ "$GIT_STAT" != '' ]; then
echo "Unable to release. Uncommitted changes detected!"
exit 1
fi

echo ""
echo "Releasing $VERSION_TAG"
echo ""

echo "Bumping version in files"
bump_version() {
local file="$1"
if [ "$(uname)" = "Darwin" ]; then
sed -i '' 's/AEM_CLI_VERSION:-"[^\"]*"/AEM_CLI_VERSION:-"'"$VERSION"'"/g' "$file"
# shellcheck disable=SC2016
sed -i '' 's/aem\@v[^\`]*\`/aem@v'"$VERSION"\`'/g' "$file"
else
sed -i 's/AEM_CLI_VERSION:-"[^\"]*"/AEM_CLI_VERSION:-"'"$VERSION"'"/g' "$file"
# shellcheck disable=SC2016
sed -i 's/aem\@v[^\`]*\`/aem@v'"$VERSION"\`'/g' "$file"
fi
}
bump_version "README.MD"
bump_version "pkg/project/common/aemw"

echo "Pushing version bump"
git commit -a -m "Release $VERSION_TAG" || echo "No changes to commit"
git push || echo "Nothing to push"

echo "Pushing release tag '$VERSION_TAG'"
git tag "$VERSION_TAG"
git push origin "$VERSION_TAG" || echo "Tag already exists or cannot push"
Loading
Loading