Skip to content

Fix generation of BIDS changelog #8

Fix generation of BIDS changelog

Fix generation of BIDS changelog #8

---
name: GitHub_Changelog_Generator
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true
jobs:
github_changelog_generator:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: ["3.2"]
steps:
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies
run: |
gem install github_changelog_generator
- name: Check version
run: |
github_changelog_generator --version
- name: Build changelog
run: |
mkdir ~/changelog_build
github_changelog_generator \
--exclude-tags-regex "^(?!v).*?$" \
--user bids-standard \
--project bids-specification \
--token ${{ secrets.GITHUB_TOKEN }} \
--output ~/changelog_build/CHANGES.md \
--header-label "# Changelog" \
--release-branch master \
--no-issues \
--no-filter-by-milestone \
--no-compare-link \
--pr-label "" \
--enhancement-label "" \
--bugs-label "" \
--exclude-labels "exclude-from-changelog"
- name: Append changelog from pre-GitHub times
run: |
cat ${{ github.workspace }}/src/pregh-changes.md >> ~/changelog_build/CHANGES.md
- name: Print out complete changelog
run: |
cat ~/changelog_build/CHANGES.md
- name: Archive changelog
uses: actions/upload-artifact@v4
with:
name: changelog_pre_lint
path: |
~/changelog_build/CHANGES.md
lint_generated_changelog:
needs: github_changelog_generator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download previously build changelog
uses: actions/download-artifact@v4
with:
name: changelog_pre_lint
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install remark and extensions
run: |
npm install `cat npm-requirements.txt`
- name: Remark on autogenerated CHANGES.md
run: |
head -n 100 ~/changelog_build/CHANGES.md
npx remark-cli ~/changelog_build/CHANGES.md --rc-path ${{ github.workspace }}/.remarkrc --output ~/changelog_build/CHANGES.md
head -n 100 ~/changelog_build/CHANGES.md
sed -i 's/* /- /' ~/changelog_build/CHANGES.md
head -n 100 ~/changelog_build/CHANGES.md
npx remark-cli ~/changelog_build/CHANGES.md --frail --rc-path ${{ github.workspace }}/.remarkrc
- name: Archive linted changelog
uses: actions/upload-artifact@v4
with:
name: changelog_post_lint
path: |
~/changelog_build/CHANGES.md
commit_generated_changelog:
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
needs: lint_generated_changelog
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download previously build changelog
uses: actions/download-artifact@v4
with:
name: changelog_post_lint
- name: Changelog deployment
run: |
if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then
mv ~/changelog_build/CHANGES.md ${{ github.workspace }}/src/CHANGES.md
merge_message=$(git log -1 | grep Merge | grep "pull")
PR_number=$(echo $merge_message | cut -d ' ' -f 4)
git config credential.helper 'cache --timeout=120'
git config user.email "[email protected]"
git config user.name "bids-maintenance"
git add ${{ github.workspace }}/src/CHANGES.md
git commit -m "[DOC] Auto-generate changelog entry for PR ${PR_number}"
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/bids-standard/bids-specification.git master
else
echo "Did not detect a "Merge commit" to master, or detected a Release ... doing nothing."
fi