diff --git a/.gitignore b/.gitignore index 5005962aee..2015eb221f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ .env stacks -/info.json +/deploy/docker/fs/opt/appsmith/info.json # to ignore the node_modeules folder node_modules diff --git a/deploy/docker/.gitignore b/deploy/docker/.gitignore deleted file mode 100644 index 51b4a89f32..0000000000 --- a/deploy/docker/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -test/* -stacks/* \ No newline at end of file diff --git a/scripts/generate_info_json.sh b/scripts/generate_info_json.sh index 8eac9534e3..3f1cb70010 100755 --- a/scripts/generate_info_json.sh +++ b/scripts/generate_info_json.sh @@ -8,24 +8,16 @@ commit_sha="$(git rev-parse HEAD)" # Base URL of the current repository on GitHub. base_url="$(git remote get-url origin | sed 's,^git@github\.com:,https://github.com/,; s/\.git$//')" -git_ref="${GITHUB_HEAD_REF-}" -if [[ -z "$git_ref" ]]; then - # If the GITHUB_HEAD_REF environment variable is not set, then we are not running in a GitHub Actions workflow. - # In that case, we will use the current branch name as the git ref. - git_ref="$(git symbolic-ref HEAD || echo)" +if [[ "${GITHUB_REF-}" =~ ^refs/tags/v ]]; then + version="${GITHUB_REF#refs/tags/v}" +else + latest_released_version="$(git ls-remote --tags --sort=-v:refname "$(git remote | head -1)" 'v*' | awk -F/ '{print $NF; exit}')" + echo "latest_released_version = $latest_released_version" >&2 + next_version="$(echo "$latest_released_version" | awk -F. -v OFS=. '{ $NF++; print }')" + echo "next_version = $next_version" >&2 + version="$next_version-SNAPSHOT" fi -# Tag, if any, on the HEAD commit. -# Output of this `describe` command is described at https://git-scm.com/docs/git-describe#_examples. -git_tag="$( - # If HEAD is a commit in the `master` branch, then `git describe --tags` will give a relevant tag name. - if git merge-base --is-ancestor HEAD origin/master; then - git describe --tags --match 'v*' --dirty --broken | sed 's/-g.*$//' - fi - # This will look like `v1.9.30` when HEAD is the tag `v1.9.30`, or something like `v1.9.30-10` when HEAD is 10 commits - # ahead of the tag `v1.9.30`. -)" - if [[ -n ${GITHUB_RUN_ID-} ]]; then github_run_url="$base_url/actions/runs/$GITHUB_RUN_ID/attempts/${GITHUB_RUN_ATTEMPT-1}" fi @@ -33,10 +25,9 @@ fi jq -n \ --arg commitSha "$commit_sha" \ --arg commitUrl "$base_url/commit/$commit_sha" \ - --arg gitRef "$git_ref" \ --arg githubRef "${GITHUB_REF-}" \ - --arg gitNearestTag "$git_tag" \ --arg githubRunUrl "${github_run_url-}" \ + --arg version "$version" \ --arg imageBuiltAt "$(date -u -Iseconds)" \ --argjson isCI "${CI:-false}" \ '$ARGS.named' | tee "$(git rev-parse --show-toplevel)/deploy/docker/fs/opt/appsmith/info.json"