2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-21 13:24:11 +03:00

refactor: ci and build (#7340)

* chore: add mise

* chore: re-position ci

* chore: move sponsors script

* chore: fix yml

* chore: yml

* fix: yml

* fix: yml

* chore: tweak sponsor yml

* chore: implement security suggestion

* chore: update templates for issues and PRs and update all workflows

* fix: copilot feedback

* feat: always run CI

* fix: linked resources

* chore: cancel run if new run starts

* feat: generate release notes with copilot
This commit is contained in:
Jay
2026-01-25 18:17:31 +02:00
committed by GitHub
parent ab06109b40
commit 8ff6c19e2d
23 changed files with 273 additions and 848 deletions
-71
View File
@@ -1,71 +0,0 @@
name: 'CI'
on:
push:
branches:
- '*'
- '*/*'
- '**'
- '!sponsors'
pull_request:
branches:
- '*'
- '*/*'
- '**'
- '!sponsors'
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
fail-fast: false
steps:
- uses: actions/checkout@v6
with:
persist-credentials: true
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v47
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
- name: Check changes
id: changed-ignored
uses: tj-actions/changed-files@v47
with:
files: |
**.md
sandbox/**
examples/**
.github/**
templates/**
bin/**
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: npm
if: steps.changed-ignored.outputs.only_modified == 'false'
- run: npm ci
if: steps.changed-ignored.outputs.only_modified == 'false'
- run: npm run build
if: steps.changed-ignored.outputs.only_modified == 'false'
- name: Run Server tests
run: npm run test:node
if: steps.changed-ignored.outputs.only_modified == 'false'
# We run browser tests only on one version of the node, since client tests do not depend on the server environment.
- name: Run browser tests
run: npm run test:browser
if: steps.changed-ignored.outputs.only_modified == 'false' && matrix.node-version == '22.x'
- name: Run package tests
run: npm run test:package
if: steps.changed-ignored.outputs.only_modified == 'false'
-47
View File
@@ -1,47 +0,0 @@
name: 'CodeQL'
on:
push:
branches:
- '*'
- '*/*'
- '**'
- '!sponsors'
pull_request:
branches:
- '*'
- '*/*'
- '**'
- '!sponsors'
schedule:
- cron: '21 23 * * 5'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
-16
View File
@@ -1,16 +0,0 @@
name: 'Dependency Review'
on: [pull_request]
permissions:
contents: read
jobs:
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v6
with:
persist-credentials: false
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
-32
View File
@@ -1,32 +0,0 @@
name: "PR Labeler"
on:
pull_request_target:
workflow_dispatch:
inputs:
prs:
required: false
description: "pr number"
jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Set PR number
id: set-pr
run: |
echo "Using PR number: ${{ github.event.inputs.prs || github.event.pull_request.number }}"
echo "pr=${{ github.event.inputs.prs || github.event.pull_request.number }}" >> $GITHUB_OUTPUT
- uses: actions/labeler@v6
with:
pr-number: ${{ steps.set-pr.outputs.pr }}
-51
View File
@@ -1,51 +0,0 @@
name: notify
on:
#workflow_run:
# workflows: ["publish"]
# types:
# - completed
#repository_dispatch:
# types: [ notify ]
#release:
# types: [published]
# branches:
# - main
# - 'v**'
#push:
# tags:
# - 'v[0-9]+.[0-9]+.[0-9]+'
# branches:
# - main
# - 'v**'
workflow_dispatch:
inputs:
tag:
required: false
jobs:
notify:
runs-on: ubuntu-latest
#if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
#- name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 18
cache: npm
- run: npm ci
- name: Notify published PRs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node ./bin/actions/notify_published.js --tag ${{ github.event.inputs.tag || github.event.release.tag_name }}
-30
View File
@@ -1,30 +0,0 @@
name: NPM Tag
on:
workflow_dispatch:
inputs:
version:
required: true
tag:
required: true
default: "latest"
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- uses: actions/setup-node@v6
with:
node-version: 18
registry-url: https://registry.npmjs.org/
############# TAG RELEASE ##############
- name: Tag release
run: npm dist-tag add axios@${{ github.event.inputs.version }} ${{ github.event.inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
-85
View File
@@ -1,85 +0,0 @@
name: Release PR
on:
workflow_dispatch:
inputs:
type:
type: choice
description: Choose release type
options:
- auto
- patch
- minor
- major
default: auto
beta:
type: boolean
description: Prerelease
default: false
jobs:
releaseIt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run build
- name: Prepare release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPE_ARG: ${{ fromJSON('{"auto":"", "patch":"patch", "minor":"minor", "major":"major"}')[github.event.inputs.type] }}
BETA_ARG: ${{ github.event.inputs.beta == 'true' && '--preRelease=beta' || '' }}
run: npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github $BETA_ARG $DRY_ARG
- name: Show git status
if: failure()
run: git status && git diff
- name: Add contributors list to CHANGELOG.md
run: npm run release:changelog:fix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v3
- name: Generate PR body
id: body
uses: mathiasvr/command-output@v1
with:
run: node ./bin/pr.js
- name: Create pull request
uses: peter-evans/create-pull-request@v7
id: cpr
with:
branch: release
delete-branch: true
commit-message: 'chore(release): v${{ steps.package-version.outputs.current-version}}'
title: '[Release] v${{ steps.package-version.outputs.current-version}}'
body: |
${{ steps.body.outputs.stdout }}
## Release notes:
${{ steps.extract-release-notes.outputs.release_notes }}
labels: |
release
bot
signoff: false
#team-reviewers: |
# owners
# maintainers
#assignees: jasonsaayman
#reviewers: jasonsaayman
draft: false
- name: Show PR link
if: ${{ steps.cpr.outputs.pull-request-url }}
run: |
echo "Axios Release v${{ steps.package-version.outputs.current-version}}' pull request - ${{ steps.cpr.outputs.pull-request-url }}"
+31 -75
View File
@@ -1,85 +1,41 @@
name: Publish
name: Publish package to NPM
on:
pull_request:
types:
- closed
branches:
- main
- 'v**'
workflow_dispatch:
push:
tags:
- "v*.*.*"
permissions:
contents: write
id-token: write
jobs:
publish:
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && github.event.pull_request.head.label == 'axios:release')
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: "Release PR info"
if: github.event_name != 'workflow_dispatch'
run: echo "PR ${{ github.event.number }}"
- uses: actions/checkout@v6
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- uses: actions/setup-node@v6
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@main
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v3
- name: Check versions
run: node ./bin/check-build-version.js
############# TAG RELEASE ##############
- name: "Push tag v${{ steps.package-version.outputs.current-version }}"
uses: rickstaa/action-create-tag@v1
id: tag_version
with:
tag: "v${{ steps.package-version.outputs.current-version }}"
############# RESOLVE NPM TAG ##############
- name: NPM TAG
id: 'npm_tag'
run: node ./bin/resolveNPMTag.js
############# GITHUB RELEASE ##############
- name: "Create a GitHub release v${{ steps.package-version.outputs.current-version }}"
uses: ncipollo/release-action@v1
with:
tag: "v${{ steps.package-version.outputs.current-version }}"
name: "Release v${{ steps.package-version.outputs.current-version }}"
body: |
## Release notes:
${{ steps.extract-release-notes.outputs.release_notes }}
############# NPM RELEASE ##############
- name: Publish the release to NPM
run: npm publish --provenance --access public --tag ${{ steps.npm_tag.outputs.tag || 'latest' }}
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
notify:
needs: [publish]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Setup node
- name: Checkout repo
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 18
node-version: 24.x
cache: npm
- run: npm ci
############# Add release comments and tags to published PRs ##############
- name: Notify published PRs
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Publish to NPM
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create release tag on GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: node ./bin/actions/notify_published.js --tag ${{ github.event.inputs.tag || github.event.release.tag_name }}
TAG: ${{ github.ref_name }}
run: |
gh release create "$TAG" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${TAG#v}" \
--generate-notes
+72
View File
@@ -0,0 +1,72 @@
name: Create release branch
on:
workflow_dispatch:
inputs:
type:
type: choice
description: Choose release type
options:
- auto
- patch
- minor
- major
default: auto
beta:
type: boolean
description: Prerelease
default: false
permissions:
contents: write
pull-requests: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Bump version
id: bump_version
uses: phips28/gh-action-bump-version@v9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
version-type: ${{ github.event.inputs.type }}
default: ${{ github.event.inputs.beta == true && 'prerelease' || 'patch' }}
commit-message: "chore(release): prepare release ${{version}}"
tag-prefix: "v"
skip-tag: true
skip-push: true
- name: Build project
run: npm run build
- name: Run unit tests
run: npm run test:node
- name: Run package tests
run: npm run test:package
- name: Run browser tests
run: npm run test:browser
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore(release): prepare release ${{ steps.bump_version.outputs.newTag }}"
branch: "release/${{ steps.bump_version.outputs.newTag }}"
title: "chore(release): prepare release ${{ steps.bump_version.outputs.newTag }}"
body: "This PR prepares the release ${{ steps.bump_version.outputs.newTag }}."
base: main
maintainer-can-modify: true
draft: false
labels: |
type::automated-pr
priority::high
commit::chore
+61
View File
@@ -0,0 +1,61 @@
name: Continuous integration
on:
pull_request:
branches:
- "*"
- "*/*"
- "**"
- "!sponsors"
- "!release/**"
permissions:
contents: read
security-events: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
ci:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x, 20.x, 22.x, 24.x]
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v6
with:
persist-credentials: true
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Run unit tests
run: npm run test:node
- name: Run package tests
run: npm run test:package
- name: Run browser tests
run: npm run test:browser
if: matrix.node-version == '24.x'
- name: Dependency Review
uses: actions/dependency-review-action@v4
if: matrix.node-version == '24.x'
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: javascript
queries: security-extended,security-and-quality
if: matrix.node-version == '24.x'
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
if: matrix.node-version == '24.x'
-72
View File
@@ -1,72 +0,0 @@
name: Update Readme sponsor list
on:
workflow_dispatch:
repository_dispatch:
types:
- webhook
schedule:
# Run at 0000 daily
- cron: '0 1 * * *'
jobs:
sponsors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 16
cache: npm
- run: npm ci
- name: Check sponsors updates
id: sponsors
run: node ./bin/sponsors.js
- name: Notify status
if: ${{ steps.sponsors.outputs.changed == 'true'}}
run: |
echo "Sponsor block has changed. Creating PR with updates..."
- name: Read sponsors.md file content
if: ${{ steps.sponsors.outputs.changed == 'true'}}
id: read_file
run: |
echo 'CONTENT<<EOF' >> $GITHUB_ENV
cat ./temp/sponsors.md >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
shell: bash
- name: Echo
run: |
echo "$CONTENT"
- name: Create pull request
if: ${{ steps.sponsors.outputs.changed == 'true'}}
uses: peter-evans/create-pull-request@v7
id: cpr
with:
branch: sponsors
delete-branch: true
commit-message: 'chore(sponsor): update sponsor block'
title: '[Chore] Update sponsor block'
body: |
**New sponsor block update:**
${{ env.CONTENT }}
labels: |
pr::docs
bot
automerge
signoff: false
#team-reviewers: |
# owners
# maintainers
#assignees: jasonsaayman
#reviewers: jasonsaayman
draft: false
- name: Show PR link
if: ${{ steps.sponsors.outputs.changed == 'true'}}
run: |
echo "Sponsor block has changed. Creating PR..."
echo "Axios Release v${{ steps.package-version.outputs.current-version}}' pull request - ${{ steps.cpr.outputs.pull-request-url }}"
-34
View File
@@ -1,34 +0,0 @@
name: 'Close Stale'
on:
schedule:
- cron: '0 0 * * 1'
jobs:
stale:
permissions:
issues: write # for actions/stale to close stale issues
pull-requests: write # for actions/stale to close stale PRs
runs-on: ubuntu-latest
steps:
- name: Close Stale Issues
uses: actions/stale@v10
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: |
Hello! :wave:
This issue is being automatically marked as stale because it has not been updated in a while. Please confirm that the issue is still present and reproducible. If no updates or new comments are received the issue will be closed in a few days.
Thanks.
stale-pr-message: |
Hello! :wave:
This pull request is being automatically marked as stale because it has not been updated in a while. Please confirm that the issue is still present and reproducible. If no updates or new comments are received the pull request will be closed in a few days.
Thanks.
stale-issue-label: 'status:stale'
stale-pr-label: 'status:stale'
only-labels: 'status:more info needed'
days-before-stale: 30
days-before-close: 14
@@ -0,0 +1,64 @@
name: Update readme sponsor block
on:
workflow_dispatch:
repository_dispatch:
types:
- webhook
schedule:
- cron: "0 1 * * *"
permissions:
contents: write
pull-requests: write
jobs:
sponsors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 24.x
cache: npm
- name: Install dependencies
run: npm ci
- name: Check if sponsors require updates
id: sponsors-requires-update
run: node ../../bin/update-sponsors.js
- name: Read sponsors.md file content
run: |
echo 'CONTENT<<EOF' >> $GITHUB_ENV
cat ./temp/sponsors.md >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
shell: bash
if: steps.sponsors-requires-update.outputs.changed == 'true'
- name: Echo sponsors content
run: |
echo "$CONTENT"
if: steps.sponsors-requires-update.outputs.changed == 'true'
- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
branch: sponsors
delete-branch: true
commit-message: "chore(sponsor): update sponsor block"
title: "[Chore] Update sponsor block"
body: |
**New sponsor block update:**
${{ env.CONTENT }}
labels: |
commit::docs
priority::high
type::automated-pr
signoff: false
draft: false
if: steps.sponsors-requires-update.outputs.changed == 'true'