|
| 1 | +on: |
| 2 | + push: |
| 3 | + tags: |
| 4 | + - "v*" |
| 5 | + |
| 6 | +name: Create Release |
| 7 | + |
| 8 | +jobs: |
| 9 | + create-release: |
| 10 | + name: Publish Release |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Checkout |
| 14 | + uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - name: Pull all submodule |
| 17 | + run: git submodule update --init --recursive |
| 18 | + |
| 19 | + - name: Setup Node.js |
| 20 | + uses: actions/setup-node@v2 |
| 21 | + with: |
| 22 | + node-version: "16" |
| 23 | + |
| 24 | + - name: Setup Git |
| 25 | + run: | |
| 26 | + git config user.name '${{secrets.MAINTAINER_NAME}}' |
| 27 | + git config user.email '${{secrets.MAINTAINER_EMAIL}}' |
| 28 | +
|
| 29 | + - name: Update package.json |
| 30 | + run: | |
| 31 | + # Extract the version from the git tag (e.g., "v1.0.0") |
| 32 | + version=$(echo "${{ github.ref }}" | sed -e 's/^refs\/tags\/v//') |
| 33 | +
|
| 34 | + # Update the package.json version using Node.js script |
| 35 | + node - <<EOF |
| 36 | + const fs = require('fs'); |
| 37 | + const packageJson = JSON.parse(fs.readFileSync('package.json')); |
| 38 | + packageJson.version = "$version"; |
| 39 | + fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2)); |
| 40 | + EOF |
| 41 | +
|
| 42 | + - uses: pnpm/action-setup@v2 |
| 43 | + name: Install pnpm |
| 44 | + id: pnpm-install |
| 45 | + with: |
| 46 | + version: 7 |
| 47 | + run_install: false |
| 48 | + |
| 49 | + - name: Get pnpm store directory |
| 50 | + id: pnpm-cache |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + - uses: actions/cache@v3 |
| 56 | + name: Setup pnpm cache |
| 57 | + with: |
| 58 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 59 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-pnpm-store- |
| 62 | +
|
| 63 | + - name: Install dependencies |
| 64 | + run: pnpm install |
| 65 | + |
| 66 | + - name: Build nextjs pages |
| 67 | + run: pnpm run build |
| 68 | + |
| 69 | + - uses: actions/create-release@v1 |
| 70 | + id: create_release |
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + with: |
| 74 | + tag_name: ${{ github.ref }} |
| 75 | + release_name: ${{ github.ref }} |
| 76 | + draft: true |
0 commit comments