Skip to content

feat/test-deploy - 배포 테스트 #5

feat/test-deploy - 배포 테스트

feat/test-deploy - 배포 테스트 #5

Workflow file for this run

name: CI & Release (pnpm, secure + optimized)
on:
push:
branches: [main]
tags:
- 'v*' # v로 시작하는 태그가 푸시될 때 (예: v1.0.0)
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: corepack enable
- name: Cache pnpm store
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile
- run: pnpm test --if-present
release:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- run: corepack enable
- name: Cache pnpm store
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
- run: pnpm install --frozen-lockfile
- run: pnpm build
- name: Configure npm auth
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Verify npm user
run: npm whoami
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Pack package for test
run: pnpm pack
- name: Test local install
run: npm install ./$(ls *.tgz | head -n 1)
- name: Publish to npm
run: pnpm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# 배포 성공 후에만 Release 생성
- name: Create GitHub Release
uses: actions/github-script@v7
with:
script: |
const tagName = context.ref.replace('refs/tags/', '');
try {
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tagName,
name: `Release ${tagName}`,
body: `🚀 Package successfully published to NPM!\n\n**Version:** ${tagName}\n**Package:** [recomponent](https://www.npmjs.com/package/recomponent)`,
draft: false,
prerelease: tagName.includes('-')
});
console.log(`✅ Release ${tagName} created successfully!`);
} catch (error) {
if (error.status === 422) {
console.log(`⚠️ Release ${tagName} already exists`);
} else {
throw error;
}
}
# 이메일 알림
- name: Send email
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 587
secure: true
username: ${{ secrets.GMAIL_USERNAME }}
password: ${{ secrets.GMAIL_APP_PASSWORD }}
subject: 🚀 Release ${{ github.ref_name }} completed
body: |
Your package has been successfully published to NPM!
Version: ${{ github.ref_name }}
Package: recomponent
Repository: ${{ github.repository }}
to: [email protected] # 여기에 실제 이메일 주소 입력
from: [email protected]