Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 13 additions & 26 deletions .github/workflows/contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
schedule:
# Weekly on Saturdays.
- cron: "30 1 * * 6"
push:
branches: [main]

jobs:
update-contributors:
Expand All @@ -18,8 +16,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Update contributor list
id: contrib_list
Expand All @@ -31,39 +27,30 @@ jobs:
use_username: false
commit_message: "update contributors information"

- name: Get contributors count
id: get_contributors
- name: Update contributors count
id: count
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

run: |
OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
REPO=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)
QUERY='query { repository(owner: \"'"$OWNER"'\", name: \"'"$REPO"'\") { collaborators { totalCount } } }'

CONTRIBUTORS=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/$OWNER/$REPO/contributors?per_page=100" | \
"/repos/$GITHUB_REPOSITORY/contributors?per_page=100" | \
jq '[.[] | select(.type != "Bot" and (.login | test("\\[bot\\]$") | not) and (.login | test("-bot$") | not))] | length')

echo "Total contributors: $CONTRIBUTORS"
echo "contributors=$CONTRIBUTORS" >> $GITHUB_OUTPUT

- name: Update MAINTAINERS.md
run: |
CONTRIBUTORS="${{ steps.get_contributors.outputs.contributors }}"

perl -i -pe 's/(<!--CONTRIBUTOR COUNT START-->).*?(<!--CONTRIBUTOR COUNT END-->)/$1 '"$CONTRIBUTORS"' $2/' MAINTAINERS.md

git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add MAINTAINERS.md
git commit -m "update contributors count to $CONTRIBUTORS" || exit 0

- name: Push protected
uses: CasperWA/push-protected@v2
# The default branch is protected, so the count goes in through a pull request.
# The contributor list above opens its own pull request for the same reason.
- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}

branch: main
commit-message: "update contributors count to ${{ steps.count.outputs.contributors }}"
title: "update contributors count to ${{ steps.count.outputs.contributors }}"
body: "Weekly contributor count refresh for MAINTAINERS.md."
branch: automated/update-contributors-count
delete-branch: true
add-paths: MAINTAINERS.md
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- main
- dev

permissions:
contents: read

jobs:
eslint:
name: ESLint
Expand Down
48 changes: 26 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,42 @@ jobs:

- name: Get release label
id: label
env:
LABELS: ${{ toJson(github.event.pull_request.labels) }}
run: |
labels='${{ toJson(github.event.pull_request.labels) }}'

if echo "$labels" | grep -q 'release:major'; then
if echo "$LABELS" | grep -q 'release:major'; then
echo "bump=major" >> $GITHUB_OUTPUT
elif echo "$labels" | grep -q 'release:minor'; then
elif echo "$LABELS" | grep -q 'release:minor'; then
echo "bump=minor" >> $GITHUB_OUTPUT
elif echo "$labels" | grep -q 'release:patch'; then
elif echo "$LABELS" | grep -q 'release:patch'; then
echo "bump=patch" >> $GITHUB_OUTPUT
elif echo "$labels" | grep -q 'release:none'; then
elif echo "$LABELS" | grep -q 'release:none'; then
echo "No release requested."
echo "bump=none" >> $GITHUB_OUTPUT
else
echo "No release label found. Add one of:"
echo "release:patch | release:minor | release:major | release:none"
exit 1
fi

- name: Exit if no release needed
if: steps.label.outputs.bump == 'none'
run: |
echo "No release requested. Exiting."
exit 0

- name: Get latest version tag
if: steps.label.outputs.bump != 'none'
id: version
run: |
latest=$(git tag --list 'v*' --sort=-v:refname | head -n 1)
echo "latest=$latest" >> $GITHUB_OUTPUT

- name: Calculate next version
if: steps.label.outputs.bump != 'none'
id: next
env:
LATEST: ${{ steps.version.outputs.latest }}
BUMP: ${{ steps.label.outputs.bump }}
run: |
version=${{ steps.version.outputs.latest }}
bump=${{ steps.label.outputs.bump }}

version=${version#v}
version=${LATEST#v}
IFS='.' read -r major minor patch <<< "$version"

case "$bump" in
case "$BUMP" in
major)
major=$((major+1))
minor=0
Expand All @@ -80,17 +77,24 @@ jobs:
echo "next=$next" >> $GITHUB_OUTPUT

- name: Create version tag
if: steps.label.outputs.bump != 'none'
env:
NEXT: ${{ steps.next.outputs.next }}
run: |
git tag ${{ steps.next.outputs.next }}
git push origin ${{ steps.next.outputs.next }}
git tag "$NEXT"
git push origin "$NEXT"

- name: Update moving major tag (v1)
if: steps.label.outputs.bump != 'none'
env:
NEXT: ${{ steps.next.outputs.next }}
run: |
major=$(echo "${{ steps.next.outputs.next }}" | cut -d. -f1)
git tag -f $major
git push origin $major --force
major="${NEXT%%.*}"
git tag -f "$major"
git push origin "$major" --force

- name: Create GitHub Release
if: steps.label.outputs.bump != 'none'
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.next.outputs.next }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/repoHygieneCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
- "main"
workflow_dispatch:

permissions:
contents: read

jobs:
check-first-run:
name: Check For First Run
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- main
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-gov-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
cache: "npm"

- name: Install dependencies
run: npm install
run: npm ci

# Discovery results record each repo's last push time, so a restored cache
# lets the run skip every repo that has not changed. The run id in the key
Expand Down
Loading