Skip to content
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
107 changes: 107 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Create Release PR

on:
workflow_dispatch:
inputs:
type:
type: choice
description: Choose release type
options:
- auto
- patch
- minor
- major
default: auto

jobs:
releaseIt:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Configure git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: npm

- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Prepare release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPE_ARG: ${{ fromJSON('{"auto":"", "patch":"patch", "minor":"minor", "major":"major"}')[github.event.inputs.type] }}
run: npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github.release

- name: Show git status
if: failure()
run: git status && git diff

- name: Get new version
id: package-version
run: echo "current-version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v3

- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
id: cpr
with:
branch: release
delete-branch: true
commit-message: 'chore(release): v${{ steps.package-version.outputs.current-version }}'
title: '[Release] v${{ steps.package-version.outputs.current-version }}'
body: |
## Release v${{ steps.package-version.outputs.current-version }}

This PR was automatically generated to release version **v${{ steps.package-version.outputs.current-version }}**.

### Changes
- 📦 Version bumped in `package.json`
- 📝 `CHANGELOG.md` updated with release notes
- 🔨 Package built and ready for publishing

### Release notes:
${{ steps.extract-release-notes.outputs.release_notes }}

---

### What happens after merge?
When this PR is merged to main, the following will automatically happen:
1. ✅ Create git tag `v${{ steps.package-version.outputs.current-version }}`
2. ✅ Create GitHub release with release notes
3. ✅ Publish to npm registry as `@requestly/alternative-importers@${{ steps.package-version.outputs.current-version }}`

---
**🚀 Ready to release? Review and merge this PR to publish!**
labels: |
release
bot
signoff: false
draft: false

- name: Show PR link
if: ${{ steps.cpr.outputs.pull-request-url }}
run: |
echo "✨ Release PR created successfully!"
echo "🔗 ${{ steps.cpr.outputs.pull-request-url }}"
echo "📦 Version: v${{ steps.package-version.outputs.current-version }}"

99 changes: 99 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: Publish Release

on:
pull_request:
types:
- closed
branches:
- main
workflow_dispatch:

jobs:
publish:
# Only run if PR is merged and comes from 'release' branch (from the same repo), or if manually triggered
if: |
github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.merged == true &&
github.event.pull_request.head.label == 'requestly:release')
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write

steps:
- name: Release PR info
if: github.event_name != 'workflow_dispatch'
run: |
echo "🎉 Release PR merged!"
echo "📋 PR #${{ github.event.number }}"
echo "🌿 Branch: ${{ github.event.pull_request.head.ref }}"

- uses: actions/checkout@v6

- name: Configure git
run: |
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org/'

- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Get package version
id: package-version
run: echo "current-version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT

- name: Create npm package tarball
run: npm pack

- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v3

############# TAG RELEASE ##############
- name: "Push tag v${{ steps.package-version.outputs.current-version }}"
uses: rickstaa/action-create-tag@v1
id: tag_version
with:
tag: "v${{ steps.package-version.outputs.current-version }}"

############# GITHUB RELEASE ##############
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: "v${{ steps.package-version.outputs.current-version }}"
name: "v${{ steps.package-version.outputs.current-version }}"
body: ${{ steps.extract-release-notes.outputs.release_notes }}
artifacts: "requestly-alternative-importers-${{ steps.package-version.outputs.current-version }}.tgz"

############# NPM RELEASE ##############
- name: Publish to NPM
run: npm publish --provenance --access public # Add npm --tag (dist-tag) later

- name: Success notification
run: |
echo "::notice::✅ Successfully published @requestly/alternative-importers@${{ steps.package-version.outputs.current-version }}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✨ Release v${{ steps.package-version.outputs.current-version }} Published!"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
echo "📦 NPM Package:"
echo " https://www.npmjs.com/package/@requestly/alternative-importers"
echo ""
echo "🏷️ Git Tag:"
echo " v${{ steps.package-version.outputs.current-version }}"
echo ""
echo "📝 GitHub Release:"
echo " https://github.com/${{ github.repository }}/releases/tag/v${{ steps.package-version.outputs.current-version }}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

59 changes: 59 additions & 0 deletions .release-it.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import type { Config } from 'release-it';

const config: Config = {
git: {
commitMessage: 'chore(release): v${version}',
tagName: 'v${version}',
requireBranch: false,
requireCleanWorkingDir: false,
push: false,
commit: true,
tag: false,
},
github: {
release: false,
releaseName: 'v${version}',
draft: false,
preRelease: false,
},
npm: {
publish: false,
},
hooks: {
'before:init': ['npm run build'],
'after:release': 'echo Successfully prepared release v${version}',
},
plugins: {
'@release-it/conventional-changelog': {
preset: 'angular',
infile: 'CHANGELOG.md',
parserOpts: {
headerPattern: /^(?:\[(.*)\]\s*)?(\w*)(?:\((.*)\))?: (.*)$/,
headerCorrespondence: ['ticket', 'type', 'scope', 'subject'],
},
writerOpts: {
transform: (commit: any) => {
// Make sure chore commits are included
if (commit.type === 'feat') {
commit.type = '✨ Features';
} else if (commit.type === 'fix') {
commit.type = '🐛 Bug Fixes';
} else if (commit.type === 'chore') {
commit.type = '🔧 Chores';
} else if (commit.type === 'refactor') {
commit.type = '♻️ Refactoring';
} else {
return; // Hide other types
}

commit.subject = commit.header

return commit;
},
},
},
},
};

export default config;

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


Loading