Skip to content

[CI] Add workflow to automatically publish JS packages on npm #2615

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

Merged
merged 1 commit into from
Mar 2, 2025
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
50 changes: 50 additions & 0 deletions .github/workflows/release-on-npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release on NPM

on:
push:
tags:
- 'v*.*.*'
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be only for tags v2.*.* as you checkout the 2.x branch ?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true, we can be more precise to prevent any issues


jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: 2.x

- name: Configure Git
run: |
git config --global user.email ""
git config --global user.name "Symfony"

- name: Extract version from tag
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

- run: corepack enable
- uses: actions/setup-node@v4
with:
cache: 'yarn'
cache-dependency-path: |
yarn.lock
package.json
src/**/package.json
- run: yarn --immutable

- name: Update version of JS packages
run: yarn workspaces foreach -A version --immediate "${{ env.VERSION }}"

- name: Commit changes
run: |
git add .
git commit -m "Update versions to ${{ env.VERSION }}"

- name: Publish on NPM
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: yarn workspaces foreach -A --no-private npm publish --access public --tolerate-republish

- name: Push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git push origin 2.x
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
nodeLinker: node-modules
npmAuthToken: ${NPM_AUTH_TOKEN-}
Loading