ci: fix issue miss the step install dependencies when running gh acti… #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish to NPM | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository 🛎️ | |
uses: actions/checkout@v4 | |
- name: Setup Node.js ⚙️ | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Install Dependencies 📦 | |
run: npm install | |
- name: Build Project 📦 | |
run: npm run build | |
approval: | |
needs: [build-and-deploy] | |
runs-on: ubuntu-latest | |
environment: release-deploy | |
steps: | |
- name: Approval for release 📦 | |
uses: trstringer/manual-approval@v1 | |
with: | |
secret: ${{ secrets.GITHUB_TOKEN }} | |
approvers: ${{ secrets.APPROVERS }} | |
publish-and-release: | |
needs: [approval] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository 🛎️ | |
uses: actions/checkout@v4 | |
- name: Install Dependencies 📦 | |
run: npm install | |
- name: Build Project 📦 | |
run: npm run build | |
- name: Configure Git User 👤 | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Bump version and Create Tag 📦 | |
run: | | |
VERSION=$(npm version patch -m "chore: bump version to %s") | |
echo "New version $VERSION" | |
echo "tag=$VERSION" >> $GITHUB_ENV | |
git push --follow-tags | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
- name: Publish to npm 📦 | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create GitHub Release 📦 | |
uses: softprops/action-gh-release@v1 | |
with: | |
repository: MinhOmega/react-theme-switch-animation | |
tag_name: ${{ env.tag }} | |
name: 'Release ${{ env.tag }}' | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |