ci(pipeline): 👷 Update CI system #1
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 & Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
types: [opened, synchronize] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
id-token: write | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: 📦 Build | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v2 | |
with: | |
version: 7 | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "lts/*" | |
cache: pnpm | |
- run: pnpm install --no-frozen-lockfile | |
- name: Test | |
run: pnpm test | |
- name: Build | |
run: pnpm build | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifact | |
path: dist | |
release: | |
name: 🚀 Release | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
needs: build | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-artifact | |
path: dist | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "lts/*" | |
- name: Set correct path | |
run: sed -i "s/\/dist//g" package.json | |
- name: Copy files | |
run: | | |
cp README.md dist | |
cp LICENSE dist | |
cp package.json dist | |
cp .npmignore dist | |
- name: Semantic Release | |
uses: cycjimmy/semantic-release-action@v3 | |
with: | |
extra_plugins: | | |
@semantic-release/changelog | |
@semantic-release/git | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |