mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 08:13:23 +00:00
fix: resolve GitHub Actions workflow issues
🐛 **Fixes Applied:**
### Package Manager Alignment
- Switched from npm to pnpm throughout workflow to match project setup
- Added proper pnpm cache configuration for faster builds
- Used pnpm/action-setup@v4 for pnpm installation
- Kept npm for version bumping only (pnpm lacks version command)
### Deprecated Action Replacement
- Replaced deprecated actions/create-release@v1 with gh CLI
- Updated to use gh release create for better reliability
- Improved release notes formatting with proper escaping
### Missing Output Declaration
- Added proper outputs declaration to version-and-publish job
- Exposed new-version, current-version, and version-type outputs
- Fixed notify-success job to properly reference outputs
- Added conditional check to prevent empty version notifications
### Additional Improvements
- Enhanced lockfile handling for both package-lock.json and pnpm-lock.yaml
- Added --no-git-checks flag to pnpm publish for CI environment
- Improved success notification with version change details
This commit is contained in:
66
.github/workflows/version-and-publish.yml
vendored
66
.github/workflows/version-and-publish.yml
vendored
@@ -13,6 +13,10 @@ jobs:
|
|||||||
version-and-publish:
|
version-and-publish:
|
||||||
if: github.event_name == 'push' || (github.event.pull_request.merged == true && (contains(github.event.pull_request.head.ref, 'version/major') || contains(github.event.pull_request.head.ref, 'version/minor') || contains(github.event.pull_request.head.ref, 'version/patch')))
|
if: github.event_name == 'push' || (github.event.pull_request.merged == true && (contains(github.event.pull_request.head.ref, 'version/major') || contains(github.event.pull_request.head.ref, 'version/minor') || contains(github.event.pull_request.head.ref, 'version/patch')))
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
new-version: ${{ steps.version-bump.outputs.new-version }}
|
||||||
|
current-version: ${{ steps.version-bump.outputs.current-version }}
|
||||||
|
version-type: ${{ steps.version-type.outputs.type }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -26,16 +30,32 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: '18'
|
node-version: '18'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
cache: 'npm'
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 8
|
||||||
|
|
||||||
|
- name: Get pnpm store directory
|
||||||
|
shell: bash
|
||||||
|
run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Setup pnpm cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ env.STORE_PATH }}
|
||||||
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-pnpm-store-
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: npm test
|
run: pnpm test
|
||||||
|
|
||||||
- name: Run build
|
- name: Run build
|
||||||
run: npm run build
|
run: pnpm build
|
||||||
|
|
||||||
- name: Determine version bump type
|
- name: Determine version bump type
|
||||||
id: version-type
|
id: version-type
|
||||||
@@ -118,7 +138,7 @@ jobs:
|
|||||||
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
||||||
echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
# Bump version
|
# Bump version (npm is used for version command as pnpm doesn't have equivalent)
|
||||||
npm version ${{ steps.version-type.outputs.type }} --no-git-tag-version
|
npm version ${{ steps.version-type.outputs.type }} --no-git-tag-version
|
||||||
|
|
||||||
# Get new version
|
# Get new version
|
||||||
@@ -126,7 +146,14 @@ jobs:
|
|||||||
echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
echo "new-version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
# Create commit with changelog
|
# Create commit with changelog
|
||||||
git add package.json package-lock.json
|
git add package.json
|
||||||
|
# Add lockfile if it exists (npm version might create package-lock.json)
|
||||||
|
if [ -f package-lock.json ]; then
|
||||||
|
git add package-lock.json
|
||||||
|
fi
|
||||||
|
if [ -f pnpm-lock.yaml ]; then
|
||||||
|
git add pnpm-lock.yaml
|
||||||
|
fi
|
||||||
git commit -m "chore: bump version to v$NEW_VERSION
|
git commit -m "chore: bump version to v$NEW_VERSION
|
||||||
|
|
||||||
${{ steps.changelog.outputs.changelog }}"
|
${{ steps.changelog.outputs.changelog }}"
|
||||||
@@ -146,20 +173,16 @@ jobs:
|
|||||||
|
|
||||||
- name: Publish to NPM
|
- name: Publish to NPM
|
||||||
if: steps.version-type.outputs.type != 'none'
|
if: steps.version-type.outputs.type != 'none'
|
||||||
run: npm publish --access public
|
run: pnpm publish --access public --no-git-checks
|
||||||
env:
|
env:
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
if: steps.version-type.outputs.type != 'none'
|
if: steps.version-type.outputs.type != 'none'
|
||||||
uses: actions/create-release@v1
|
run: |
|
||||||
env:
|
gh release create "v${{ steps.version-bump.outputs.new-version }}" \
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
--title "Release v${{ steps.version-bump.outputs.new-version }}" \
|
||||||
with:
|
--notes "# Release v${{ steps.version-bump.outputs.new-version }}
|
||||||
tag_name: v${{ steps.version-bump.outputs.new-version }}
|
|
||||||
release_name: Release v${{ steps.version-bump.outputs.new-version }}
|
|
||||||
body: |
|
|
||||||
# Release v${{ steps.version-bump.outputs.new-version }}
|
|
||||||
|
|
||||||
${{ steps.changelog.outputs.changelog }}
|
${{ steps.changelog.outputs.changelog }}
|
||||||
|
|
||||||
@@ -169,15 +192,15 @@ jobs:
|
|||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
```bash
|
\`\`\`bash
|
||||||
npm install @xtr-dev/payload-mailing@${{ steps.version-bump.outputs.new-version }}
|
npm install @xtr-dev/payload-mailing@${{ steps.version-bump.outputs.new-version }}
|
||||||
```
|
\`\`\`
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
See the [README](https://github.com/xtr-dev/payload-mailing#readme) for usage instructions and full documentation.
|
See the [README](https://github.com/xtr-dev/payload-mailing#readme) for usage instructions and full documentation."
|
||||||
draft: false
|
env:
|
||||||
prerelease: false
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
notify-success:
|
notify-success:
|
||||||
if: github.event_name == 'push' || (github.event.pull_request.merged == true && (contains(github.event.pull_request.head.ref, 'version/major') || contains(github.event.pull_request.head.ref, 'version/minor') || contains(github.event.pull_request.head.ref, 'version/patch')))
|
if: github.event_name == 'push' || (github.event.pull_request.merged == true && (contains(github.event.pull_request.head.ref, 'version/major') || contains(github.event.pull_request.head.ref, 'version/minor') || contains(github.event.pull_request.head.ref, 'version/patch')))
|
||||||
@@ -185,7 +208,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Success notification
|
- name: Success notification
|
||||||
|
if: needs.version-and-publish.outputs.new-version != ''
|
||||||
run: |
|
run: |
|
||||||
echo "🎉 Successfully published version ${{ needs.version-and-publish.outputs.new-version }} to NPM!"
|
echo "🎉 Successfully published version ${{ needs.version-and-publish.outputs.new-version }} to NPM!"
|
||||||
echo "📦 Package: https://www.npmjs.com/package/@xtr-dev/payload-mailing"
|
echo "📦 Package: https://www.npmjs.com/package/@xtr-dev/payload-mailing"
|
||||||
echo "🏷️ GitHub Release: https://github.com/xtr-dev/payload-mailing/releases/tag/v${{ needs.version-and-publish.outputs.new-version }}"
|
echo "🏷️ GitHub Release: https://github.com/xtr-dev/payload-mailing/releases/tag/v${{ needs.version-and-publish.outputs.new-version }}"
|
||||||
|
echo "🔄 Version Type: ${{ needs.version-and-publish.outputs.version-type }}"
|
||||||
|
echo "📈 Version Change: v${{ needs.version-and-publish.outputs.current-version }} → v${{ needs.version-and-publish.outputs.new-version }}"
|
||||||
Reference in New Issue
Block a user