Skip to content
Merged
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
21 changes: 21 additions & 0 deletions .github/workflows/npm-publish-reusable.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Publish npm package

env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

on:
workflow_call:
inputs:
Expand All @@ -15,27 +18,41 @@ jobs:
publish:
name: Publish ${{ inputs.name }}
runs-on: ubuntu-latest

steps:
# Ensuring that only one PR-environment-creation per branch will run at a time
- name: Mutex setup
uses: ben-z/gh-action-mutex@v1.0-alpha-7
with:
branch: "mutex/${{ github.event.workflow_run.head_branch }}-publish"

# Default the GK_TOKEN to GITHUB_TOKEN if not present
- name: Look for GH_TOKEN
if: env.GH_TOKEN == ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "GH_TOKEN=${GITHUB_TOKEN}" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
ref: main
token: ${{ env.GH_TOKEN }}

- name: Setup pnpm
uses: pnpm/action-setup@v2.4.0
with:
version: 'latest'

- uses: actions/setup-node@v4
with:
node-version: "18.x"
cache: "pnpm"

- name: Setup npmrc
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Changelog
id: version-bump
uses: Enterwell/ChangelogManager-GitHub-Action@v3
Expand All @@ -44,13 +61,16 @@ jobs:
should-bump-version: true
changes-location: ./packages/${{ inputs.name }}/changes
path-to-project-file: ./packages/${{ inputs.name }}/package.json

- name: Commit changelog changes
uses: EndBug/add-and-commit@v9.1.3
with:
message: "[skip ci] [version-bump] Automated commit for version ${{ steps.version-bump.outputs.bumped-semantic-version }}"

- run: pnpm i --frozen-lockfile --filter=${{ inputs.name }}...
- run: pnpm build --filter=${{ inputs.name }}...
- run: pnpm publish --access public --filter=${{ inputs.name }} --no-git-checks

- name: Git tags update
run: |
git config user.name github-actions
Expand All @@ -61,6 +81,7 @@ jobs:
git tag -f "${{ inputs.name }}/v${{ steps.version-bump.outputs.bumped-major-part }}.${{ steps.version-bump.outputs.bumped-minor-part }}" "${{ inputs.name }}/v${{ steps.version-bump.outputs.bumped-semantic-version }}"

git push -f --tags

- name: Create GitHub release
run: gh release create "${{ inputs.name }}/v${{ steps.version-bump.outputs.bumped-semantic-version }}" -n "${{ steps.version-bump.outputs.new-changes }}"
env:
Expand Down