|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Release |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Set up Node.js |
| 18 | + uses: actions/setup-node@v3 |
| 19 | + with: |
| 20 | + node-version: '20.8.1' |
| 21 | + |
| 22 | + - name: Cache node_modules |
| 23 | + uses: actions/cache@v3 |
| 24 | + with: |
| 25 | + path: node_modules |
| 26 | + key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }} |
| 27 | + restore-keys: | |
| 28 | + ${{ runner.os }}-node-modules- |
| 29 | +
|
| 30 | + - name: Install dependencies |
| 31 | + if: steps.cache.outputs.cache-hit != 'true' |
| 32 | + run: npm install --legacy-peer-deps |
| 33 | + |
| 34 | + - name: Build application |
| 35 | + run: npm run build |
| 36 | + |
| 37 | + - name: Bump version and release |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + run: npx semantic-release |
| 41 | + |
| 42 | + - name: Retrieve plugin version and name |
| 43 | + id: get_version |
| 44 | + run: | |
| 45 | + echo "PLUGIN_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV |
| 46 | + echo "PLUGIN_NAME=$(node -p -e "require('./package.json').name")" >> $GITHUB_ENV |
| 47 | +
|
| 48 | + - name: Zip build files in a temporary directory |
| 49 | + run: | |
| 50 | + mkdir -p /tmp/build |
| 51 | + zip -r /tmp/build/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip ./build |
| 52 | +
|
| 53 | + - name: Create release and attach zip file |
| 54 | + env: |
| 55 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + run: | |
| 57 | + TAG=v${{ env.PLUGIN_VERSION }} |
| 58 | + RELEASE_TITLE="v${{ env.PLUGIN_VERSION }}" |
| 59 | + DESCRIPTION="Release for plugin ${{ env.PLUGIN_NAME }}. Version: ${{ env.PLUGIN_VERSION }}. [Download latest build](https://github.com/${{ github.repository }}/raw/builds/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip)" |
| 60 | + |
| 61 | + # Create a GitHub release |
| 62 | + gh release create $TAG /tmp/build/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip \ |
| 63 | + --title "$RELEASE_TITLE" \ |
| 64 | + --notes "$DESCRIPTION" |
| 65 | + shell: bash |
0 commit comments