diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 87a96c5..c132374 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,43 +1,48 @@ -name: Publish NPM Package - +name: Publish Packages on: release: types: [published] +env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: publish-npm-packages: runs-on: ubuntu-latest + permissions: + contents: 'write' + packages: 'write' + actions: 'read' steps: - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: 20 registry-url: https://registry.npmjs.org/ - - name: Install dependencies + + - name: Install Dependencies run: npm ci + - name: Git Identity run: | - git config --global user.name '${GITHUB_ACTOR}' - git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITHUB_ACTOR: ${{ github.actor }} - - name: Prepare release branch + git config user.name github-actions + git config user.email github-actions@github.com + + - name: Prepare Release Branch run: | git switch -c "release/${GITHUB_REF:11}" git push origin "release/${GITHUB_REF:11}" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish packages + + - name: Publish Packages run: npx lerna publish ${{ github.event.release.tag_name }} --yes env: NODE_AUTH_TOKEN: ${{secrets.npm_token}} - - name: Remove release branch + - name: Remove Release Branch run: | git switch main git branch -D "release/${GITHUB_REF:11}" git push origin --delete "release/${GITHUB_REF:11}" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}