Skip to content

Commit ef6719e

Browse files
committed
build: tweak output when flags are supplied and add workflow
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent f907f8c commit ef6719e

File tree

3 files changed

+143
-2
lines changed

3 files changed

+143
-2
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2025 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Workflow name:
20+
name: generate_monthly_changelog
21+
22+
# Workflow triggers:
23+
on:
24+
# Run the workflow at midnight UTC on the first day of each month:
25+
schedule:
26+
- cron: '0 0 1 * *'
27+
28+
# Allow the workflow to be manually run:
29+
workflow_dispatch:
30+
31+
# Global permissions:
32+
permissions:
33+
# Allow read-only access to the repository contents:
34+
contents: read
35+
36+
# Workflow jobs:
37+
jobs:
38+
# Generate a monthly changelog:
39+
generate-monthly-changelog:
40+
# Define a display name:
41+
name: 'Generate Monthly Changelog'
42+
43+
# Define the type of virtual host machine:
44+
runs-on: ubuntu-latest
45+
46+
# Workflow steps:
47+
steps:
48+
- name: 'Checkout source repository'
49+
# Pin action to full length commit SHA
50+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
51+
with:
52+
# Specify whether to remove untracked files before checking out the repository:
53+
clean: false
54+
55+
# Limit clone depth to the most recent commit:
56+
fetch-depth: 1
57+
58+
# Token for accessing the repository:
59+
token: ${{ secrets.STDLIB_BOT_FGPAT_REPO_READ }}
60+
61+
# Avoid storing GitHub token in local Git configuration:
62+
persist-credentials: false
63+
64+
# Install Node.js:
65+
- name: 'Install Node.js'
66+
# Pin action to full length commit SHA
67+
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
68+
with:
69+
node-version: '20' # 'lts/*'
70+
timeout-minutes: 5
71+
72+
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
73+
- name: 'Install dependencies'
74+
run: |
75+
make install-node-modules || make install-node-modules || make install-node-modules
76+
timeout-minutes: 15
77+
78+
- name: 'Checkout monthly changelog repository'
79+
# Pin action to full length commit SHA
80+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
81+
with:
82+
# Code coverage repository:
83+
repository: 'stdlib-js/www-blog-monthly-changelog'
84+
85+
# File path to checkout to:
86+
path: './www-blog-monthly-changelog'
87+
88+
# Specify whether to remove untracked files before checking out the repository:
89+
clean: false
90+
91+
# Limit clone depth to the most recent commit:
92+
fetch-depth: 1
93+
94+
# Token for accessing the repository:
95+
token: ${{ secrets.STDLIB_BOT_FGPAT_REPO_READ }}
96+
97+
# Avoid storing GitHub token in local Git configuration:
98+
persist-credentials: false
99+
100+
# Generate changelog for last month:
101+
- name: 'Generate changelog for last month'
102+
run: |
103+
UNTIL=$(date +"%Y-%m-01")
104+
node -e "
105+
var generate = require( '@stdlib/_tools/changelog/generate' );
106+
var changelog = generate( '@stdlib', {
107+
'flags': {
108+
'since': '$UNTIL - 1 week',
109+
'until': '$UNTIL'
110+
}
111+
});
112+
console.log( changelog.content );
113+
" > ./www-blog-monthly-changelog/monthly_changelog_$UNTIL.md
114+
115+
# Import GPG key to sign commits:
116+
- name: 'Import GPG key to sign commits'
117+
# Pin action to full length commit SHA
118+
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
119+
with:
120+
gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }}
121+
passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }}
122+
git_user_signingkey: true
123+
git_commit_gpgsign: true
124+
125+
# Commit and push changes:
126+
- name: 'Commit and push changes'
127+
env:
128+
REPO_GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
129+
USER_NAME: stdlib-bot
130+
run: |
131+
cd ./www-blog-monthly-changelog
132+
git config --local user.email "[email protected]"
133+
git config --local user.name "stdlib-bot"
134+
git add .
135+
git commit -m "Add monthly changelog" || exit 0
136+
git push "https://$USER_NAME:[email protected]/stdlib-js/www-blog-monthly-changelog.git" main

lib/node_modules/@stdlib/_tools/changelog/generate/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ changelog = generate( '@stdlib/ndarray', {
9999

100100
<section class="notes">
101101

102+
- When `flags` are supplied, the generated changelog skips printing empty releases and uses a flat output format.
103+
102104
</section>
103105

104106
<!-- /.notes -->

lib/node_modules/@stdlib/_tools/changelog/generate/lib/main.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ function generate( pkg, options ) {
341341
}
342342
}
343343

344-
if ( isNamespacePkg ) {
344+
if ( isNamespacePkg && !opts.flags ) {
345345
str += releaseSectionStart( nextVersion );
346346
str += '## ' + ( nextVersion || 'Unreleased' ) + ' (' + formatDate() + ')\n\n';
347347
if ( commits.unreleased.length > 0 ) {
@@ -374,7 +374,7 @@ function generate( pkg, options ) {
374374
str += sectionEnd( 'release' );
375375
}
376376
}
377-
if ( isNamespacePkg ) {
377+
if ( isNamespacePkg && !opts.flags ) {
378378
for ( i = releases.length-1; i >= 0; i-- ) {
379379
version = releases[ i ][ 0 ];
380380
str += releaseSectionStart( version );
@@ -407,6 +407,9 @@ function generate( pkg, options ) {
407407
version = releases[ i ][ 0 ];
408408
summary = releaseSummary( commits[ version ] );
409409
if ( !summary ) {
410+
if ( opts.flags ) {
411+
continue;
412+
}
410413
summary = PLACEHOLDER_SUMMARY;
411414
}
412415
str += releaseSectionStart( version );

0 commit comments

Comments
 (0)