Skip to content

Create release

Create release #3

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@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
- name: Bump version
run: |
new_version="${{ inputs.version }}"
sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/g" composer.json
sed -i "s/\"version\": \".*\"/\"version\": \"$new_version\"/g" package.json
sed -i "s/Version:.*$/Version: $new_version/g" prompress.php
sed -i "s/define( 'PROMPRESS_VERSION', '.*' );/define( 'PROMPRESS_VERSION', '$new_version' );/g" prompress.php
composer update --lock --ignore-platform-reqs --no-install
npm install --package-lock-only
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@github.com"
git add composer.json composer.lock package.json package-lock.json prompress.php
git commit -m "Bump version to $new_version"
git push origin HEAD:main
- name: Install NPM dependencies
run: npm ci
- name: Get changelog entries
id: changelog
run: |
changelog=$(git log --oneline $(git describe --tags --abbrev=0 @^)..@)
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 local/
git rm -r node_modules/
git rm -r src/
git rm -r .gitignore
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