-
Notifications
You must be signed in to change notification settings - Fork 13
70 lines (61 loc) · 1.97 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check if version has changed
id: check_version
run: |
VERSION=$(grep -oP "Version:\s*\K\d+(\.\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: false
- name: Build
if: steps.check_version.outputs.release == 'true'
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
run: |
yarn install
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 }}