From 50bf91c14fed08e8c6f5487ff7c1d74d2a848031 Mon Sep 17 00:00:00 2001 From: Timo Reichl Date: Sat, 23 Dec 2023 02:32:46 +0100 Subject: [PATCH] Add script to generate changelog Signed-off-by: Timo Reichl --- .github/workflows/build-push-tag.yml | 20 ++++++++++++++++++-- .gitignore | 1 + scripts/changelog.sh | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100755 scripts/changelog.sh diff --git a/.github/workflows/build-push-tag.yml b/.github/workflows/build-push-tag.yml index eee1d6a..ad9b67b 100644 --- a/.github/workflows/build-push-tag.yml +++ b/.github/workflows/build-push-tag.yml @@ -81,7 +81,11 @@ jobs: docker push ${DOCKER_HUB_PREFIX}/${REGISTRY_IMAGE}:${docker_image}-${{ github.ref_name }} done - # Copied and modified from k0sctl: https://github.com/k0sproject/k0sctl/blob/main/.github/workflows/release.yaml + # Copied and modified from k0sctl: https://github.com/xdeb-org/xdeb-install/blob/main/.github/workflows/release.yml + - name: Add safe git directory + if: ${{ inputs.tag }} + run: git config --global --add safe.directory /__w/steamcmd/* + ## Ugly hack to get the tag name ## github.ref gives the full reference like refs.tags.v0.0.1-beta1 - name: Get branch name to draft release @@ -90,11 +94,23 @@ jobs: run: | echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> ${GITHUB_OUTPUT} + - name: Unshallow git history + if: ${{ inputs.tag }} + env: + TAG_NAME: ${{ steps.branch_name.outputs.TAG_NAME }} + run: | + git fetch --unshallow + git checkout ${TAG_NAME} + + - name: Generate changelog + if: ${{ inputs.tag }} + run: ./scripts/changelog.sh + - name: Draft release if: ${{ inputs.tag }} uses: softprops/action-gh-release@v1 with: - body: "${{ steps.branch_name.outputs.TAG_NAME }}" + body_path: public/changelog.md tag_name: ${{ steps.branch_name.outputs.TAG_NAME }} name: ${{ steps.branch_name.outputs.TAG_NAME }} draft: true # So we can manually edit before publishing diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a48cf0d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +public diff --git a/scripts/changelog.sh b/scripts/changelog.sh new file mode 100755 index 0000000..1b52454 --- /dev/null +++ b/scripts/changelog.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +repository_url="https://github.com/thetredev/steamcmd" + +first_tag=$(git tag --sort=-version:refname | head -n 2 | tail -1) +second_tag=$(git tag --sort=-version:refname | head -n 1) + +mkdir -p public + +echo "## What's Changed" > public/changelog.md + +echo >> public/changelog.md +git log ${first_tag}..${second_tag} --pretty=format:"- %s (%h)" >> public/changelog.md +echo >> public/changelog.md +echo >> public/changelog.md + +echo "**Full Changelog**: [\`${first_tag}..${second_tag}\`](${repository_url}/compare/${first_tag}..${second_tag})" >> public/changelog.md