Skip to content

👷 ci: skip tag creation for non-versioned commits #5

👷 ci: skip tag creation for non-versioned commits

👷 ci: skip tag creation for non-versioned commits #5

Workflow file for this run

name: Release
on:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.8.1'
- name: Cache node_modules
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install --legacy-peer-deps
- name: Build application
run: npm run build
- name: Bump version and release
id: semantic_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release | tee semantic_release_output.txt
if grep -q "Published release" semantic_release_output.txt; then
echo "NEW_VERSION_RELEASED=true" >> $GITHUB_ENV
else
echo "NEW_VERSION_RELEASED=false" >> $GITHUB_ENV
fi
continue-on-error: true
- name: Retrieve plugin version and name
if: ${{ env.NEW_VERSION_RELEASED == 'true' }}
id: get_version
run: |
echo "PLUGIN_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
echo "PLUGIN_NAME=$(node -p -e "require('./package.json').name")" >> $GITHUB_ENV
- name: Zip build files in a temporary directory
if: ${{ env.NEW_VERSION_RELEASED == 'true' }}
run: |
mkdir -p /tmp/build
mkdir -p /tmp/build/${PLUGIN_NAME}-${PLUGIN_VERSION}
mv ./build/* /tmp/build/${PLUGIN_NAME}-${PLUGIN_VERSION}/
cd /tmp/build
zip -r ${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip ${PLUGIN_NAME}-${PLUGIN_VERSION}
- name: Create release and attach zip file
if: ${{ env.NEW_VERSION_RELEASED == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG=v${{ env.PLUGIN_VERSION }}
RELEASE_TITLE="v${{ env.PLUGIN_VERSION }}"
DOWNLOAD_URL="https://github.com/${{ github.repository }}/releases/download/${TAG}/${PLUGIN_NAME}-${PLUGIN_VERSION}.zip"
DESCRIPTION="Release for plugin ${{ env.PLUGIN_NAME }}. Version: ${{ env.PLUGIN_VERSION }}. [Download latest build](${DOWNLOAD_URL})"
# Create a GitHub release
gh release create $TAG /tmp/build/${{ env.PLUGIN_NAME }}-${{ env.PLUGIN_VERSION }}.zip \
--title "$RELEASE_TITLE" \
--notes "$DESCRIPTION"
shell: bash