v1.4.0 #34
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Check if version has changed | |
id: check_version | |
run: | | |
VERSION=$(grep -oP "Version:\s*\K\d+(\.\d+)*(-\w+)?(\.\d+)?" woocommerce-pos.php) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
git fetch --prune --unshallow | |
LAST_TAG=$(git describe --tags --abbrev=0) | |
if [[ "v$VERSION" == "$LAST_TAG" ]]; then | |
echo "Version has not changed. Skipping release..." | |
echo "::set-output name=release::false" | |
else | |
echo "Version has changed. Creating new release..." | |
echo "::set-output name=release::true" | |
fi | |
- name: Create Release | |
if: steps.check_version.outputs.release == 'true' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: Release v${{ env.VERSION }} | |
draft: true | |
prerelease: ${{ contains(env.VERSION, '-beta') }} | |
- name: Build | |
if: steps.check_version.outputs.release == 'true' | |
env: | |
YARN_ENABLE_IMMUTABLE_INSTALLS: false | |
run: | | |
yarn install | |
composer prefix-dependencies | |
composer install --no-dev | |
yarn build:js | |
- name: Sync to Temporary Directory | |
if: steps.check_version.outputs.release == 'true' | |
run: | | |
mkdir temp_dir | |
rsync -av --prune-empty-dirs --exclude-from='.distignore' ./ temp_dir/ | |
- name: Compress and Upload ZIP | |
if: steps.check_version.outputs.release == 'true' | |
run: | | |
cd temp_dir | |
zip -r ../woocommerce-pos.zip . | |
cd .. | |
gh release upload v${{ env.VERSION }} woocommerce-pos.zip --clobber | |
rm -rf temp_dir | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |