name: Generate Release Notes on: release: types: [created] jobs: update-release-notes: name: Update Release with Commit Notes runs-on: ubuntu-latest permissions: contents: write steps: - name: Check out the repo uses: actions/checkout@v4 with: fetch-depth: 0 - name: Get previous tag id: prev_tag run: | # Get all tags sorted by version, exclude the current tag, take the first result CURRENT_TAG="${{ github.event.release.tag_name }}" PREV_TAG=$(git tag --sort=-version:refname | grep -v "^${CURRENT_TAG}$" | head -n 1) if [ -z "$PREV_TAG" ]; then echo "No previous tag found, will use initial commit" # Use the initial commit as the starting point PREV_TAG=$(git rev-list --max-parents=0 HEAD) fi echo "Previous tag/commit: $PREV_TAG" echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT - name: Generate commit list id: commits env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | REPO_URL="https://github.com/${{ github.repository }}" CURRENT_TAG="${{ github.event.release.tag_name }}" PREV_TAG="${{ steps.prev_tag.outputs.tag }}" # Always use range format - PREV_TAG is guaranteed to be set (either previous tag or initial commit) RANGE="${PREV_TAG}..${CURRENT_TAG}" echo "Generating commits for range: $RANGE" # Generate commit list with format: title - @nickname - sha with link # Using tformat instead of format to ensure trailing newline COMMITS="" while IFS='|' read -r SHA SHORT_SHA TITLE AUTHOR || [ -n "$SHA" ]; do [ -z "$SHA" ] && continue # Try to get GitHub username from commit API USERNAME=$(gh api "repos/${{ github.repository }}/commits/${SHA}" --jq '.author.login' 2>/dev/null || echo "") if [ -n "$USERNAME" ]; then AUTHOR_INFO="@${USERNAME}" else AUTHOR_INFO="${AUTHOR}" fi # Check if this is a PR merge commit if [[ "$TITLE" =~ ^Merge\ pull\ request\ \#([0-9]+) ]]; then PR_NUMBER="${BASH_REMATCH[1]}" # Get PR title PR_TITLE=$(gh pr view "$PR_NUMBER" --json title --jq '.title' 2>/dev/null || echo "$TITLE") COMMITS="${COMMITS}- ${PR_TITLE} (#${PR_NUMBER}) by ${AUTHOR_INFO} ([\`${SHORT_SHA}\`](${REPO_URL}/commit/${SHA}))"$'\n' else COMMITS="${COMMITS}- ${TITLE} by ${AUTHOR_INFO} ([\`${SHORT_SHA}\`](${REPO_URL}/commit/${SHA}))"$'\n' fi done < <(git log "${RANGE}" --pretty=tformat:"%H|%h|%s|%an") # Handle multiline output { echo "list<> $GITHUB_OUTPUT - name: Update Release Notes uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.event.release.tag_name }} body: | ## What's Changed ${{ steps.commits.outputs.list }} **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.prev_tag.outputs.tag }}...${{ github.event.release.tag_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} update-dockerhub-description: name: Update Docker Hub Description runs-on: ubuntu-latest steps: - name: Check out the repo uses: actions/checkout@v4 - name: Update Docker Hub description uses: peter-evans/dockerhub-description@v4 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: hemmeligapp/hemmelig readme-filepath: ./docs/docker.md