Skip to content

Create release

Create release #11

name: Create release
on:
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
default: ''
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'npm'
- name: Install NPM dependencies
run: npm ci
- name: Get changelog entries
id: changelog
run: |
changelog=$(grep -A100 -m1 -e '== Changelog ==' readme.txt)
changelog="${changelog//'%'/'%25'}"
changelog="${changelog//$'\n'/'%0A'}"
changelog="${changelog//$'\r'/'%0D'}"
echo $changelog
echo "changes=$changelog" >> $GITHUB_OUTPUT
- name: Build dependencies
run: npm run build
- name: Prepare build repository
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@github.com"
git checkout -b "release/${{ inputs.version }}"
git add -f build/*
git rm -r .github/
git rm -r src/
git rm .editorconfig
git rm .wp-env.json
git rm package.json
git rm package-lock.json
git rm phpcs.xml.dist
git commit -m "Release ${{ inputs.version }}"
git tag "${{ inputs.version }}"
git push --tags
- name: Create GitHub release
id: create_github_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ inputs.version }}
release_name: Release ${{ inputs.version }}
draft: false
body: ${{ steps.changelog.outputs.changes }}
prerelease: false