Skip to content

Commit

Permalink
ci: Auto-generate changelog (argoproj#5903)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <[email protected]>
  • Loading branch information
alexec authored May 13, 2021
1 parent ba700ee commit 37f8c7c
Show file tree
Hide file tree
Showing 7 changed files with 11,182 additions and 409 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Changelog

on:
push:
branches:
- master
- dev-*
# run every 30m to make sure it is up-to-date
schedule:
- cron: "*/30 * * * *"
jobs:
generate_changelog:
runs-on: ubuntu-latest
name: Generate changelog
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- run: git fetch --prune --prune-tags
- run: git tag -l 'v*'
# avoid invoking `make` to reduce the change of Makefile problem failing this workflow
- run: ./hack/changelog.sh > CHANGELOG.md
- name: Commit files
run: |
git config --local user.email [email protected]
git config --local user.name 'Changelog Github Actions'
git add CHANGELOG.md && git commit -s -m 'docs: Updated CHANGELOG.md' && echo "push=true" >> $GITHUB_ENV || echo "No changes to CHANGELOG.md"
- name: Push changes
if: env.push == 'true'
run: git push
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ jobs:
path: /home/runner/go/pkg/mod
key: GOMODCACHE-v2-${{ hashFiles('**/go.mod') }}
# https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions
- run: make changelog VERSION=${GITHUB_REF##*/}
- run: cat changelog
- run: make release-notes VERSION=${GITHUB_REF##*/}
- run: cat release-notes
- run: make manifests VERSION=${GITHUB_REF##*/}
- name: Print image tag (please check it is not `:latest`)
run: |
Expand All @@ -392,7 +392,7 @@ jobs:
- uses: softprops/action-gh-release@v1
with:
prerelease: ${{ startsWith(github.ref, 'refs/tags/v0') || contains(github.ref, 'rc') }}
body_path: changelog
body_path: release-notes
files: |
dist/argo-*.gz
dist/argo-*.gz.sha256
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cmd/**/debug
hack/**/debug
/argo
/argoexec
changelog
release-notes
debug.test
git-ask-pass.sh
*.iml
Expand Down
11,513 changes: 11,125 additions & 388 deletions CHANGELOG.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ else
LOG_OPTS := 'origin/master..'
endif

changelog: /dev/null
version=$(VERSION) breaking_changes=`git log --oneline --grep '!:' $(LOG_OPTS)` changes=`git log --format=' * %h %s' $(LOG_OPTS)` contributors=`git log --format=' * %an' $(LOG_OPTS) | sort -u` envsubst < hack/changelog.md > changelog
release-notes: /dev/null
version=$(VERSION) envsubst < hack/release-notes.md > release-notes

.PHONY: parse-examples
parse-examples:
Expand Down
20 changes: 20 additions & 0 deletions hack/changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env sh
set -eu

echo '# Changelog'
echo

tag=
git tag -l 'v*' | sort -rd | while read last; do
if [ "$tag" != "" ]; then
echo "## $tag ($(git log $tag -n1 --format=%as))"
echo
git --no-pager log --format=' * %h %s' $last..$tag
echo
echo "### Contributors"
echo
git --no-pager log --format=' * %an' $last..$tag | sort -u
echo
fi
tag=$last
done
15 changes: 0 additions & 15 deletions hack/changelog.md → hack/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

Find out on [our blog](https://blog.argoproj.io).

## Breaking Changes

If any.

${breaking_changes}

## Argo CLI

### Mac
Expand Down Expand Up @@ -60,12 +54,3 @@ argo version
kubectl create namespace argo
kubectl apply -n argo -f https://github.com/argoproj/argo-workflows/releases/download/${version}/install.yaml
```

## Changes

${changes}

## Contributors

${contributors}

0 comments on commit 37f8c7c

Please sign in to comment.