Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): backported publish action; #6224

Merged
merged 2 commits into from
Feb 11, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Publish
on:
pull_request:
types:
- closed
branches:
- main
- 'v**'
workflow_dispatch:
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@v3
- name: git config
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- 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@v1
- 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 }}"
############# 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
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
notify:
needs: [publish]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
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@v3
with:
node-version: 18
cache: npm
- run: npm ci
############# Add release comments and tags to published PRs ##############
# - 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 }}
19 changes: 19 additions & 0 deletions bin/check-build-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const fs = require('fs');
const assert = require('assert');
const axios = require('../index.js');

const {version} = JSON.parse(fs.readFileSync('./package.json'));

console.log('Checking versions...\n----------------------------')

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (90% of all statements in
the enclosing script
have an explicit semicolon).

console.log(`Package version: v${version}`);
console.log(`Axios version: v${axios.VERSION}`);
console.log(`----------------------------`);

assert.strictEqual(
version,
axios.VERSION,
`Version mismatch between package and Axios ${version} != ${axios.VERSION}`
);

console.log('✔️ PASSED\n');