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
96 changes: 93 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
name: Publish Package to npmjs

on:
release:
types: [published]
workflow_run:
workflows: [CI]
branches: [master]
types: [completed]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write
packages: write
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -13,8 +26,85 @@ jobs:
- run: npm i
- run: npm test

changelog:
name: Changelog
needs:
- build
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest

outputs:
skipped: ${{ steps.changelog.outputs.skipped }}
tag: ${{ steps.changelog.outputs.tag }}
clean_changelog: ${{ steps.changelog.outputs.clean_changelog }}
version: ${{ steps.changelog.outputs.version }}

env:
PR_BRANCH: release/ci-${{ github.sha }}

steps:
- name: Checkout branch
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: '0'

- name: Create release branch
run: |
git checkout -b ${{ env.PR_BRANCH }}

- name: Create Changelog
id: changelog
uses: TriPSs/conventional-changelog-action@dd19d7c07e5f620b2d6f48d547148a4b6b29e92f # v3.19.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
git-user-name: "github-actions"
git-user-email: "github-actions[bot]@users.noreply.github.com"
git-branch: ${{ env.PR_BRANCH }}
skip-git-pull: true
output-file: false
create-summary: true
skip-on-empty: false
release-count: 10

# create PR using GitHub CLI
- name: Create Changelog PR
if: steps.changelog.outputs.skipped == 'false'
run: |
gh pr create --base master --head ${{ env.PR_BRANCH }} --title 'chore(release): ${{ steps.changelog.outputs.tag }} [skip-ci]' --body '${{ steps.changelog.outputs.clean_changelog }}'
env:
GH_TOKEN: ${{ github.token }}

- name: Merge Changelog PR
if: steps.changelog.outputs.skipped == 'false'
run: |
gh pr merge --squash --auto --delete-branch ${{ env.PR_BRANCH }}
env:
GH_TOKEN: ${{ github.token }}

release:
name: GitHub Release
needs: changelog
if: github.event_name != 'pull_request' && needs.changelog.outputs.skipped == 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Create Release
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ needs.changelog.outputs.tag }}
tag_name: ${{ needs.changelog.outputs.tag }}
draft: false
generate_release_notes: true
make_latest: 'true'
prerelease: false

publish-npm:
needs: build
name: NPM Release
needs: changelog
if: github.event_name != 'pull_request' && needs.changelog.outputs.skipped == 'false'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down