From d0e8f8c4e3168a0a652c297f325814fbfcc91580 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 09:35:07 +0200 Subject: [PATCH 01/18] use default remote_docker_version --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 676383d1f1..90ac1e0998 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -98,8 +98,7 @@ jobs: docker: - image: ferrarimarco/github-changelog-generator:1.14.3 steps: - - setup_remote_docker: - version: 18.06.0-ce + - setup_remote_docker # checkout code to default ~/project - checkout - run: From 7480f72df0d07552ae786be781be8b4d67dde055 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 09:44:19 +0200 Subject: [PATCH 02/18] run changelog gen and lint even if not Merge commit --- .circleci/config.yml | 60 ++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 35 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 90ac1e0998..907fe97622 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -106,28 +106,23 @@ jobs: # $CHANGE_TOKEN is generated via the GitHub web UI, and then securely stored within CircleCI web UI command: | mkdir ~/changelog_build - git status - if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then - github_changelog_generator \ - --exclude-tags-regex "^(?!v).*?$" \ - --user bids-standard \ - --project bids-specification \ - --token ${CHANGE_TOKEN} \ - --output ~/changelog_build/CHANGES.md \ - --base ~/project/src/pregh-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" - cat ~/changelog_build/CHANGES.md - else - echo "Commit or Release, do nothing" - fi + github_changelog_generator \ + --exclude-tags-regex "^(?!v).*?$" \ + --user bids-standard \ + --project bids-specification \ + --token ${CHANGE_TOKEN} \ + --output ~/changelog_build/CHANGES.md \ + --base ~/project/src/pregh-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" + cat ~/changelog_build/CHANGES.md - persist_to_workspace: # raw generated changelog in ~/changelog_build/CHANGES.md root: ~/. @@ -151,24 +146,19 @@ jobs: name: remark on autogenerated CHANGES.md # format changelog, then use sed to change * to -, then lint changelog command: | - git status - if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then - head -n 100 ~/changelog_build/CHANGES.md - npx remark-cli ~/changelog_build/CHANGES.md --rc-path ~/project/.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 ~/project/.remarkrc - else - echo "Commit or Release, do nothing" - fi + head -n 100 ~/changelog_build/CHANGES.md + npx remark-cli ~/changelog_build/CHANGES.md --rc-path ~/project/.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 ~/project/.remarkrc - persist_to_workspace: # linted and fixed changelog in ~/changelog_build/CHANGES.md root: ~/. paths: - changelog_build - # Push built changelog to repo + # Push built changelog to repo (only if if last commit was a "Merge commit" on master) commit_generated_changelog: docker: - image: cimg/base:stable @@ -194,7 +184,7 @@ jobs: git commit -m "[DOC] Auto-generate changelog entry for PR ${PR_number}" git push https://${CHANGE_TOKEN}@github.com/bids-standard/bids-specification.git master else - echo "Commit or Release, do nothing" + echo "Did not detect a "Merge commit" to master, or detected a Release ... doing nothing." fi workflows: From 26a77057e0f5ea1bcb3bfe2548a00ca42744d9b2 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 09:48:14 +0200 Subject: [PATCH 03/18] TMP: to be reverted. testing gen and lint on non-master --- .circleci/config.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 907fe97622..aabe0b1341 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -194,16 +194,10 @@ workflows: - check_links: requires: - build_docs - - github_changelog_generator: - filters: - branches: - only: master + - github_changelog_generator - lint_generated_changelog: requires: - github_changelog_generator - filters: - branches: - only: master - commit_generated_changelog: requires: - lint_generated_changelog From 585320ac28ed9b067581cc329e1caebfe9926e51 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 10:04:01 +0200 Subject: [PATCH 04/18] try new token --- .circleci/config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aabe0b1341..56f531aa14 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -103,14 +103,16 @@ jobs: - checkout - run: name: Build changelog - # $CHANGE_TOKEN is generated via the GitHub web UI, and then securely stored within CircleCI web UI + # $CHANGELOG_GITHUB_TOKEN was generated via the GitHub web UI of the `bids-maintenance` + # GitHub user (see https://github.com/settings/tokens), and was then securely stored within + # CircleCI web UI. command: | mkdir ~/changelog_build github_changelog_generator \ --exclude-tags-regex "^(?!v).*?$" \ --user bids-standard \ --project bids-specification \ - --token ${CHANGE_TOKEN} \ + --token ${CHANGELOG_GITHUB_TOKEN} \ --output ~/changelog_build/CHANGES.md \ --base ~/project/src/pregh-changes.md \ --header-label "# Changelog" \ From 43d1cfc18acd46d6fc94d62c48ba6749daa1acfb Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 10:19:31 +0200 Subject: [PATCH 05/18] check which version we are running --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 56f531aa14..c6746971a6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -108,6 +108,7 @@ jobs: # CircleCI web UI. command: | mkdir ~/changelog_build + github_changelog_generator --version github_changelog_generator \ --exclude-tags-regex "^(?!v).*?$" \ --user bids-standard \ From d31731fe7291b44b658a774afefb332d3552b880 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 11:08:31 +0200 Subject: [PATCH 06/18] no docker, upgrade version --- .circleci/config.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c6746971a6..5636a528f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -96,11 +96,18 @@ jobs: # Automatically generate a changelog since migration from Google Docs to GitHub github_changelog_generator: docker: - - image: ferrarimarco/github-changelog-generator:1.14.3 + - image: cimg/ruby:3.2 steps: - - setup_remote_docker # checkout code to default ~/project - checkout + - run: + name: install github_changelog_generator + command: | + gem install github_changelog_generator + - run: + name: check version + command: | + github_changelog_generator --version - run: name: Build changelog # $CHANGELOG_GITHUB_TOKEN was generated via the GitHub web UI of the `bids-maintenance` @@ -108,14 +115,12 @@ jobs: # CircleCI web UI. command: | mkdir ~/changelog_build - github_changelog_generator --version github_changelog_generator \ --exclude-tags-regex "^(?!v).*?$" \ --user bids-standard \ --project bids-specification \ --token ${CHANGELOG_GITHUB_TOKEN} \ --output ~/changelog_build/CHANGES.md \ - --base ~/project/src/pregh-changes.md \ --header-label "# Changelog" \ --release-branch master \ --no-issues \ @@ -126,6 +131,10 @@ jobs: --bugs-label "" \ --exclude-labels "exclude-from-changelog" cat ~/changelog_build/CHANGES.md + - run: + name: append changelog from pre-GitHub times + command: | + cat ~/project/src/pregh-changes.md >> ~/changelog_build/CHANGES.md - persist_to_workspace: # raw generated changelog in ~/changelog_build/CHANGES.md root: ~/. From 5bed14a74e86b848f4a89c616161ba9e190152a4 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 11:15:27 +0200 Subject: [PATCH 07/18] try old token --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5636a528f5..e1e1218f65 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -119,7 +119,7 @@ jobs: --exclude-tags-regex "^(?!v).*?$" \ --user bids-standard \ --project bids-specification \ - --token ${CHANGELOG_GITHUB_TOKEN} \ + --token ${CHANGE_TOKEN} \ --output ~/changelog_build/CHANGES.md \ --header-label "# Changelog" \ --release-branch master \ From 2fc645b8f6d4378dcd860f6dc6cba94bd4d19e30 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 11:27:01 +0200 Subject: [PATCH 08/18] new token (again), different scope, and implicit --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e1e1218f65..94a02a398f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,14 +112,14 @@ jobs: name: Build changelog # $CHANGELOG_GITHUB_TOKEN was generated via the GitHub web UI of the `bids-maintenance` # GitHub user (see https://github.com/settings/tokens), and was then securely stored within - # CircleCI web UI. + # CircleCI web UI as an environment variable. This is being picked up automatically by the + # github_changelog_generator. command: | mkdir ~/changelog_build github_changelog_generator \ --exclude-tags-regex "^(?!v).*?$" \ --user bids-standard \ --project bids-specification \ - --token ${CHANGE_TOKEN} \ --output ~/changelog_build/CHANGES.md \ --header-label "# Changelog" \ --release-branch master \ From 06b33ce4d6a39d3a58aa172858e09c009b81a6da Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 11:29:43 +0200 Subject: [PATCH 09/18] try explicit again --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 94a02a398f..9d00cd4bab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,14 +112,14 @@ jobs: name: Build changelog # $CHANGELOG_GITHUB_TOKEN was generated via the GitHub web UI of the `bids-maintenance` # GitHub user (see https://github.com/settings/tokens), and was then securely stored within - # CircleCI web UI as an environment variable. This is being picked up automatically by the - # github_changelog_generator. + # CircleCI web UI as an environment variable. command: | mkdir ~/changelog_build github_changelog_generator \ --exclude-tags-regex "^(?!v).*?$" \ --user bids-standard \ --project bids-specification \ + --token ${CHANGELOG_GITHUB_TOKEN} \ --output ~/changelog_build/CHANGES.md \ --header-label "# Changelog" \ --release-branch master \ From aea6deeda38061d9aba0d12cef881beb1f5a25ea Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 11:59:36 +0200 Subject: [PATCH 10/18] try with fine grained token --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9d00cd4bab..2dd24901af 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -130,11 +130,14 @@ jobs: --enhancement-label "" \ --bugs-label "" \ --exclude-labels "exclude-from-changelog" - cat ~/changelog_build/CHANGES.md - run: name: append changelog from pre-GitHub times command: | cat ~/project/src/pregh-changes.md >> ~/changelog_build/CHANGES.md + - run: + name: print out complete changelog + command: | + cat ~/changelog_build/CHANGES.md - persist_to_workspace: # raw generated changelog in ~/changelog_build/CHANGES.md root: ~/. From e0025696f964fd0245dadd0d5a2c569c5897849c Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 12:24:15 +0200 Subject: [PATCH 11/18] try with new circleci setting --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2dd24901af..1a3a120dee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -112,7 +112,7 @@ jobs: name: Build changelog # $CHANGELOG_GITHUB_TOKEN was generated via the GitHub web UI of the `bids-maintenance` # GitHub user (see https://github.com/settings/tokens), and was then securely stored within - # CircleCI web UI as an environment variable. + # CircleCI web UI as an environment variable ("classic token", "repo scope", no expiration). command: | mkdir ~/changelog_build github_changelog_generator \ From 91fee538fa910584c9e3a347e38e533cfedea461 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 24 May 2024 12:34:49 +0200 Subject: [PATCH 12/18] try CHANGE_TOKEN, now that no longer on fork --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1a3a120dee..e6c9b0ccc0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -119,7 +119,7 @@ jobs: --exclude-tags-regex "^(?!v).*?$" \ --user bids-standard \ --project bids-specification \ - --token ${CHANGELOG_GITHUB_TOKEN} \ + --token ${CHANGE_TOKEN} \ --output ~/changelog_build/CHANGES.md \ --header-label "# Changelog" \ --release-branch master \ From ce0bcb884dcac62d176450f7f9518a6ccf41b1cc Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 31 May 2024 15:42:13 +0200 Subject: [PATCH 13/18] try gh action --- .github/workflows/changelog_generator.yml | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/changelog_generator.yml diff --git a/.github/workflows/changelog_generator.yml b/.github/workflows/changelog_generator.yml new file mode 100644 index 0000000000..3a3573f4b0 --- /dev/null +++ b/.github/workflows/changelog_generator.yml @@ -0,0 +1,56 @@ +--- +name: GitHub_Changelog_Generator + +on: + push: + branches: ["**"] + pull_request: + branches: ["**"] + +concurrency: + group: ${{ github.workflow }}-${{ github.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 }}/${{ github.repository }}/src/pregh-changes.md >> ${{ github.workspace }}/changelog_build/CHANGES.md + - name: Print out complete changelog + run: | + cat ${{ github.workspace }}/changelog_build/CHANGES.md From 81616ca44afe1916bf014b03192faf29142555a9 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 31 May 2024 16:43:42 +0200 Subject: [PATCH 14/18] migrate circleci -> gh action --- .circleci/config.yml | 119 ---------------------- .github/workflows/changelog_generator.yml | 75 +++++++++++++- .github/workflows/schemacode_ci.yml | 4 +- 3 files changed, 73 insertions(+), 125 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e6c9b0ccc0..63f1dd4ce8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -93,115 +93,6 @@ jobs: - store_artifacts: path: bids-spec.pdf - # Automatically generate a changelog since migration from Google Docs to GitHub - github_changelog_generator: - docker: - - image: cimg/ruby:3.2 - steps: - # checkout code to default ~/project - - checkout - - run: - name: install github_changelog_generator - command: | - gem install github_changelog_generator - - run: - name: check version - command: | - github_changelog_generator --version - - run: - name: Build changelog - # $CHANGELOG_GITHUB_TOKEN was generated via the GitHub web UI of the `bids-maintenance` - # GitHub user (see https://github.com/settings/tokens), and was then securely stored within - # CircleCI web UI as an environment variable ("classic token", "repo scope", no expiration). - command: | - mkdir ~/changelog_build - github_changelog_generator \ - --exclude-tags-regex "^(?!v).*?$" \ - --user bids-standard \ - --project bids-specification \ - --token ${CHANGE_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" - - run: - name: append changelog from pre-GitHub times - command: | - cat ~/project/src/pregh-changes.md >> ~/changelog_build/CHANGES.md - - run: - name: print out complete changelog - command: | - cat ~/changelog_build/CHANGES.md - - persist_to_workspace: - # raw generated changelog in ~/changelog_build/CHANGES.md - root: ~/. - paths: - - changelog_build - - # Lint and fix the auto generated changes.md file - lint_generated_changelog: - docker: - - image: cimg/node:lts - steps: - # checkout code to default ~/project - - checkout - - attach_workspace: - # the freshly built CHANGES.md will be in ~/changelog_build/CHANGES.md - at: ~/. - - run: - name: install remark and extensions - command: npm install `cat npm-requirements.txt` - - run: - name: remark on autogenerated CHANGES.md - # format changelog, then use sed to change * to -, then lint changelog - command: | - head -n 100 ~/changelog_build/CHANGES.md - npx remark-cli ~/changelog_build/CHANGES.md --rc-path ~/project/.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 ~/project/.remarkrc - - persist_to_workspace: - # linted and fixed changelog in ~/changelog_build/CHANGES.md - root: ~/. - paths: - - changelog_build - - # Push built changelog to repo (only if if last commit was a "Merge commit" on master) - commit_generated_changelog: - docker: - - image: cimg/base:stable - steps: - - setup_remote_docker - # checkout code to default ~/project - - checkout - - attach_workspace: - # fixed+linted changelog in ~/changelog_build/CHANGES.md - at: ~/. - - run: - name: Changelog deployment - # $CHANGE_TOKEN is generated via the GitHub web UI, and then securely stored within CircleCI web UI - command: | - if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then - mv ~/changelog_build/CHANGES.md ~/project/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 "bids.maintenance@gmail.com" - git config user.name "bids-maintenance" - git add ~/project/src/CHANGES.md - git commit -m "[DOC] Auto-generate changelog entry for PR ${PR_number}" - git push https://${CHANGE_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 - workflows: search_build: jobs: @@ -209,14 +100,4 @@ workflows: - check_links: requires: - build_docs - - github_changelog_generator - - lint_generated_changelog: - requires: - - github_changelog_generator - - commit_generated_changelog: - requires: - - lint_generated_changelog - filters: - branches: - only: master - build_docs_pdf diff --git a/.github/workflows/changelog_generator.yml b/.github/workflows/changelog_generator.yml index 3a3573f4b0..f29a99cb39 100644 --- a/.github/workflows/changelog_generator.yml +++ b/.github/workflows/changelog_generator.yml @@ -8,8 +8,8 @@ on: branches: ["**"] concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} + cancel-in-progress: true jobs: github_changelog_generator: @@ -50,7 +50,74 @@ jobs: --exclude-labels "exclude-from-changelog" - name: Append changelog from pre-GitHub times run: | - cat ${{ github.workspace }}/${{ github.repository }}/src/pregh-changes.md >> ${{ github.workspace }}/changelog_build/CHANGES.md + cat ${{ github.workspace }}/src/pregh-changes.md >> ~/changelog_build/CHANGES.md - name: Print out complete changelog run: | - cat ${{ github.workspace }}/changelog_build/CHANGES.md + 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 "bids.maintenance@gmail.com" + 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 diff --git a/.github/workflows/schemacode_ci.yml b/.github/workflows/schemacode_ci.yml index 0b92cd9a4d..14746534db 100644 --- a/.github/workflows/schemacode_ci.yml +++ b/.github/workflows/schemacode_ci.yml @@ -117,8 +117,8 @@ jobs: with: user: __token__ password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - skip_existing: true + repository-url: https://test.pypi.org/legacy/ + skip-existing: true - name: "Upload to PyPI (on tags)" if: startsWith(github.ref, 'refs/tags/schema-') uses: pypa/gh-action-pypi-publish@release/v1 From 048c1df62c15aa961e80c90f4432caf9e902bbdc Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 31 May 2024 17:10:24 +0200 Subject: [PATCH 15/18] tweaks: only on master, or PR to master; remove ad; fix path --- .github/workflows/changelog_generator.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changelog_generator.yml b/.github/workflows/changelog_generator.yml index f29a99cb39..026af58ddb 100644 --- a/.github/workflows/changelog_generator.yml +++ b/.github/workflows/changelog_generator.yml @@ -3,9 +3,9 @@ name: GitHub_Changelog_Generator on: push: - branches: ["**"] + branches: ["master"] pull_request: - branches: ["**"] + branches: ["master"] concurrency: group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} @@ -51,6 +51,9 @@ jobs: - name: Append changelog from pre-GitHub times run: | cat ${{ github.workspace }}/src/pregh-changes.md >> ~/changelog_build/CHANGES.md + - name: Remove the inserted advert from the file + run: | + sed -i '/This Changelog was automatically generated by/d' ~/changelog_build/CHANGES.md - name: Print out complete changelog run: | cat ~/changelog_build/CHANGES.md @@ -70,6 +73,7 @@ jobs: uses: actions/download-artifact@v4 with: name: changelog_pre_lint + path: ~/changelog_build/CHANGES.md - name: Set up Node uses: actions/setup-node@v4 with: @@ -106,6 +110,7 @@ jobs: uses: actions/download-artifact@v4 with: name: changelog_post_lint + path: ~/changelog_build/CHANGES.md - name: Changelog deployment run: | if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then From 65e59fcbc35844060879844fa3105a252491f90b Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Sat, 1 Jun 2024 10:19:54 +0200 Subject: [PATCH 16/18] try with directory --- .github/workflows/changelog_generator.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changelog_generator.yml b/.github/workflows/changelog_generator.yml index 026af58ddb..4260e5af3c 100644 --- a/.github/workflows/changelog_generator.yml +++ b/.github/workflows/changelog_generator.yml @@ -73,7 +73,7 @@ jobs: uses: actions/download-artifact@v4 with: name: changelog_pre_lint - path: ~/changelog_build/CHANGES.md + path: ~/changelog_build - name: Set up Node uses: actions/setup-node@v4 with: @@ -110,7 +110,7 @@ jobs: uses: actions/download-artifact@v4 with: name: changelog_post_lint - path: ~/changelog_build/CHANGES.md + path: ~/changelog_build - name: Changelog deployment run: | if (git log -1 --pretty=%s | grep Merge*) && (! git log -1 --pretty=%b | grep REL:) ; then From 7673e2fc3bd241fc48bd5b45d26dc8f01806bb3f Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Sat, 1 Jun 2024 15:21:41 +0200 Subject: [PATCH 17/18] fix linting --- .github/workflows/changelog_generator.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/changelog_generator.yml b/.github/workflows/changelog_generator.yml index 4260e5af3c..58da8c9cef 100644 --- a/.github/workflows/changelog_generator.yml +++ b/.github/workflows/changelog_generator.yml @@ -82,13 +82,19 @@ jobs: run: | npm install `cat npm-requirements.txt` - name: Remark on autogenerated CHANGES.md + # first remove empty lines + # then run remark to re-organize + # replace remark's bullet list "*" with "-" + # final run of remark to check everything passes now run: | - head -n 100 ~/changelog_build/CHANGES.md + head -n 25 ~/changelog_build/CHANGES.md + sed -i '/^$/d' ~/changelog_build/CHANGES.md + head -n 25 ~/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 + head -n 25 ~/changelog_build/CHANGES.md + sed -i 's/^* /- /' ~/changelog_build/CHANGES.md + head -n 25 ~/changelog_build/CHANGES.md + npx remark-cli ~/changelog_build/CHANGES.md --rc-path ${{ github.workspace }}/.remarkrc --frail - name: Archive linted changelog uses: actions/upload-artifact@v4 with: From 2eb872ef5238d598b055e6c3f4ca5b32867d4498 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Sat, 1 Jun 2024 15:42:32 +0200 Subject: [PATCH 18/18] better portioning of output --- .github/workflows/changelog_generator.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changelog_generator.yml b/.github/workflows/changelog_generator.yml index 58da8c9cef..fc06117e39 100644 --- a/.github/workflows/changelog_generator.yml +++ b/.github/workflows/changelog_generator.yml @@ -89,12 +89,15 @@ jobs: run: | head -n 25 ~/changelog_build/CHANGES.md sed -i '/^$/d' ~/changelog_build/CHANGES.md + echo $'\n------------------------------\n' head -n 25 ~/changelog_build/CHANGES.md - npx remark-cli ~/changelog_build/CHANGES.md --rc-path ${{ github.workspace }}/.remarkrc --output ~/changelog_build/CHANGES.md + npx remark ~/changelog_build/CHANGES.md --rc-path ${{ github.workspace }}/.remarkrc --output ~/changelog_build/CHANGES.md --quiet + echo $'\n------------------------------\n' head -n 25 ~/changelog_build/CHANGES.md sed -i 's/^* /- /' ~/changelog_build/CHANGES.md + echo $'\n------------------------------\n' head -n 25 ~/changelog_build/CHANGES.md - npx remark-cli ~/changelog_build/CHANGES.md --rc-path ${{ github.workspace }}/.remarkrc --frail + npx remark ~/changelog_build/CHANGES.md --rc-path ${{ github.workspace }}/.remarkrc --frail --quiet --no-stdout - name: Archive linted changelog uses: actions/upload-artifact@v4 with: