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

[FEQ] Added semantic releases automation #36

Merged
Merged
48 changes: 48 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Publish to NPM
on:
push:
branches:
- master
- next
- next-major
- alpha
- beta
- development

permissions:
contents: read # for checkout
Copy link
Contributor

@jim-deriv jim-deriv Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adrienne-deriv, can this be at the job level or is it needed globally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The job already has contents: write permission, so this is redundant, I'll remove it


jobs:
build_and_publish_npm:
name: Release
runs-on: ubuntu-latest
environment: Production
niloofar-deriv marked this conversation as resolved.
Show resolved Hide resolved
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8
with:
node-version: '20'
- name: Update to latest npm (temporary fix for audit below)
run: npm install --global npm
- name: Install dependencies
run: npm clean-install
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
niloofar-deriv marked this conversation as resolved.
Show resolved Hide resolved
run: npm audit signatures
- name: Prepublish
run: npm run prepublish
- name: Release
if: success()
env:
CI: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that NPM_TOKEN is already set in the secrets.
Also, make sure that there is already a tag for the latest version. semantic-release will use the latest tag as a reference of the current version and either bump/patch the current version when merged to master

run: npx semantic-release
Loading
Loading