Skip to content

Commit 0f4ebc7

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 8ebd6f7 + 99f74a8 commit 0f4ebc7

4 files changed

Lines changed: 152 additions & 8 deletions

File tree

.github/workflows/check_required_files.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
ref: 'develop'
5757

5858
# Refers to the repository name of the pull request:
59-
repository: ${{ github.event.pull_request.head.repo.full_name }}
59+
repository: ${{ github.event.issue.pull_request.head.repo.full_name }}
6060

6161
# Limit clone depth to the most recent commit:
6262
fetch-depth: 1
@@ -79,7 +79,7 @@ jobs:
7979
page=1
8080
files=""
8181
while true; do
82-
new_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.pull_request.number }}/files?page=$page&per_page=100" | jq -r '.[] | select(.status == "added") | .filename')
82+
new_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.issue.pull_request.number }}/files?page=$page&per_page=100" | jq -r '.[] | select(.status == "added") | .filename')
8383
if [ -z "$new_files" ]; then
8484
break
8585
fi
@@ -169,15 +169,15 @@ jobs:
169169
170170
body=""
171171
if [[ "${#missing_files[@]}" -eq 0 ]]; then
172-
body="Hi @${{ github.event.pull_request.user.login }}, thank you for your contribution!
172+
body="Hi @${{ github.event.issue.pull_request.user.login }}, thank you for your contribution!
173173
174174
:tada: Your pull request contains all required files for the new package: :tada:
175175
176176
${checkbox_list}
177177
178178
-- stdlib-bot"
179179
else
180-
body="Hi @${{ github.event.pull_request.user.login }}, thank you for your contribution! Your pull request contains a new package, but is missing some of the required files.
180+
body="Hi @${{ github.event.issue.pull_request.user.login }}, thank you for your contribution! Your pull request contains a new package, but is missing some of the required files.
181181
182182
Use the following checklist to keep track of the required files and which ones are still missing:
183183
@@ -203,7 +203,7 @@ jobs:
203203
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
204204
with:
205205
# Specify the issue or pull request number:
206-
issue-number: ${{ github.event.pull_request.number }}
206+
issue-number: ${{ github.issue.pull_request.number }}
207207

208208
# Specify the comment body:
209209
body: ${{ steps.check-required-files.outputs.comment-body }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
#
3+
# @license Apache-2.0
4+
#
5+
# Copyright (c) 2024 The Stdlib Authors.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
# Script to update years for stdlib copyright notices to the current year.
20+
#
21+
# Usage: update_copyright_years file1 [file2 file3 ...]
22+
#
23+
# Arguments:
24+
#
25+
# file1 File path.
26+
# file2 File path.
27+
# file3 File path.
28+
29+
current_year=$(date +"%Y")
30+
directory_to_scan="${1:-.}"
31+
32+
for file in ${@}; do
33+
echo "Updating copyright notice in $file..."
34+
# For macOS, adding '' after -i to specify no backup file is created.
35+
sed -i '' "s/Copyright (c) [0-9]\{4\} The Stdlib Authors./Copyright \(c\) $current_year The Stdlib Authors./g" "$file"
36+
done
37+
38+
echo "Copyright notices updated to $current_year."
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#/
1818

1919
# Workflow name:
20-
name: slash-commands
20+
name: slash_commands
2121

2222
# Workflow triggers:
2323
on:
@@ -28,10 +28,19 @@ on:
2828
jobs:
2929

3030
# Define a job for checking for required files:
31-
check-files:
31+
check_files:
3232

3333
# Define the conditions under which the job should run:
34-
if: github.event.issue.pull_request && contains(github.event.comment.body, '/stdlib check-files')
34+
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib check-files')
3535

3636
# Run reusable workflow:
3737
uses: ./.github/workflows/check_required_files.yml
38+
39+
# Define a job for updating copyright header years:
40+
update_copyright_years:
41+
42+
# Define the conditions under which the job should run:
43+
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/stdlib update-copyright-years')
44+
45+
# Run reusable workflow:
46+
uses: ./.github/workflows/update_pr_copyright_years.yml
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2024 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: update_pr_copyright_years
21+
22+
# Workflow triggers:
23+
on:
24+
25+
# Allow the workflow to be triggered by other workflows
26+
workflow_call:
27+
28+
# Workflow jobs:
29+
jobs:
30+
31+
# Define a job for updating the copyright years:
32+
update:
33+
34+
# Define a display name:
35+
name: 'Update Copyright Years'
36+
37+
# Define the type of virtual host machine:
38+
runs-on: ubuntu-latest
39+
40+
# Define the sequence of job steps...
41+
steps:
42+
43+
# Checkout the repository:
44+
- name: 'Checkout repository'
45+
# Pin action to full length commit SHA
46+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
47+
with:
48+
# Refers to the branch name of the branch being pushed:
49+
ref: ${{ github.event.pull_request.head.ref }}
50+
51+
# Token for accessing the repository:
52+
token: ${{ secrets.REPO_GITHUB_TOKEN }}
53+
54+
# Get list of changed files:
55+
- name: 'Get list of changed files'
56+
id: changed-files
57+
continue-on-error: true
58+
run: |
59+
# Get the list of changed files in pull request:
60+
ancestor_commit=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
61+
files=$(git diff --diff-filter=AM --name-only $ancestor_commit ${{ github.event.pull_request.head.sha }})
62+
echo "files=${files}" >> $GITHUB_OUTPUT
63+
64+
# Update the copyright years:
65+
- name: 'Update copyright years'
66+
id: update-years
67+
run: |
68+
files="{{ steps.changed-files.outputs.files }}"
69+
. "$GITHUB_WORKSPACE/.github/workflows/scripts/update_copyright_years" $files
70+
71+
# Disable Git hooks:
72+
- name: 'Disable Git hooks'
73+
run: |
74+
rm -rf .git/hooks
75+
76+
# Import GPG key to sign commits:
77+
- name: 'Import GPG key to sign commits'
78+
# Pin action to full length commit SHA
79+
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
80+
with:
81+
gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }}
82+
passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }}
83+
git_user_signingkey: true
84+
git_commit_gpgsign: true
85+
86+
# Commit and push changes:
87+
- name: 'Commit and push changes'
88+
env:
89+
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
90+
USER_NAME: stdlb-bot
91+
BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
92+
run: |
93+
git config --local user.email "82920195+stdlib-bot@users.noreply.github.com"
94+
git config --local user.name "stdlib-bot"
95+
git add .
96+
git commit -m "chore: update copyright years"
97+
git push "https://$USER_NAME:$REPO_GITHUB_TOKEN@github.com/stdlib-js/stdlib.git" $BRANCH_NAME

0 commit comments

Comments
 (0)