1+ name : " Release new TAG"
2+ on :
3+ push :
4+ branches :
5+ - main
6+
7+ jobs :
8+ build-and-release :
9+ name : " Release new TAG"
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout code
13+ uses : actions/checkout@v3
14+ with :
15+ fetch-depth : 0
16+
17+ - id : set-vars
18+ name : " Set variable from .plugin-data file"
19+ run : |
20+ # Get all data from .plugin-data file
21+ content=`cat ./.plugin-data`
22+ # the following lines are only required for multi line json
23+ content="${content//'%'/'%25'}"
24+ content="${content//$'\n'/'%0A'}"
25+ content="${content//$'\r'/'%0D'}"
26+ # end of optional handling for multi line json
27+ echo "::set-output name=pluginData::$content"
28+
29+ - id : check-version
30+ name : " Check version does not exists"
31+ run : |
32+ # Get the version from .plugin-data file.
33+ VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}}
34+
35+ echo "Get Branch tag"
36+ if git rev-parse "$VERSION" >/dev/null 2>&1; then
37+ echo "Tag already exists, stop now";
38+ exit 1;
39+ fi
40+ - id : build-php
41+ name : " Build project PHP"
42+ uses : shivammathur/setup-php@v2
43+ with :
44+ php-version : 8.3
45+ - run : composer install --prefer-dist --no-dev -o --ignore-platform-reqs
46+
47+ - id : commit-and-push
48+ name : " Commit and push new TAG"
49+ run : |
50+ # Get the version from .plugin-data file.
51+ VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}}
52+
53+ echo "Copy .distignore to .gitignore"
54+ cp .distignore .gitignore
55+
56+ echo "Configure git"
57+ git config --local user.email "$(git log --format='%ae' HEAD^!)"
58+ git config --local user.name "$(git log --format='%an' HEAD^!)"
59+
60+ echo "Creating branch"
61+ git checkout -b release/{$VERSION}
62+
63+ echo "Creating tag ${VERSION}"
64+ git add .
65+ git add -u
66+ git commit -m "Release version ${VERSION}"
67+ git tag ${VERSION}
68+ git push --tags
0 commit comments