diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index efb41a7..78596fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,8 +16,10 @@ jobs: uses: ./ with: config: fixtures/cliff.toml - args: --verbose --strip 'footer' --exclude-path '.github/**' + args: --verbose --strip 'footer' --exclude-path '.github/**' --tag 0.0.0 env: OUTPUT: fixtures/CHANGELOG.md - name: Print the changelog run: cat "${{ steps.git-cliff.outputs.changelog }}" + - name: Print the version + run: echo "${{ steps.git-cliff.outputs.version }}" diff --git a/Dockerfile b/Dockerfile index bca4d71..2a5b463 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,6 @@ COPY README.md / COPY LICENSE / COPY entrypoint.sh /entrypoint.sh +RUN apt-get update && apt-get install -y jq && rm -rf /var/lib/apt/lists/* + ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 518b12c..fdf9d8a 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This action generates a changelog based on your Git history using [git-cliff](ht - `changelog`: Output file that contains the generated changelog. - `content`: Content of the changelog. +- `version`: Version of the latest release. ### Environment variables diff --git a/action.yml b/action.yml index d3a1c12..d5042b1 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,8 @@ outputs: description: "output file" content: description: "content of the changelog" + version: + description: "version of the latest release" runs: using: "docker" image: "Dockerfile" diff --git a/entrypoint.sh b/entrypoint.sh index d2d78e6..2d60754 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -19,6 +19,10 @@ args=$(echo "$@" | xargs) GIT_CLIFF_OUTPUT="$OUTPUT" git-cliff $args exit_code=$? +# Retrieve context +CONTEXT="$(mktemp)" +GIT_CLIFF_OUTPUT="$CONTEXT" git-cliff $args --context + # Output to console cat "$OUTPUT" @@ -33,5 +37,8 @@ echo "EOF" >>$GITHUB_OUTPUT # Set output file echo "changelog=$OUTPUT" >>$GITHUB_OUTPUT +# Set the version output to the version of the latest release +echo "version=$(jq -r '.[0].version' $CONTEXT)" >>$GITHUB_OUTPUT + # Pass exit code to the next step echo "exit_code=$exit_code" >>$GITHUB_OUTPUT