Merge pull request #12 from mosne/ver/0.1.3 #11
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 new TAG | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-release: | |
name: "Release new TAG" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- id: set-vars | |
name: "Set variable from .plugin-data file" | |
run: | | |
# Get all data from .plugin-data file | |
content=`cat ./.plugin-data` | |
# the following lines are only required for multi line json | |
content="${content//'%'/'%25'}" | |
content="${content//$'\n'/'%0A'}" | |
content="${content//$'\r'/'%0D'}" | |
# end of optional handling for multi line json | |
echo "::set-output name=pluginData::$content" | |
- id: check-version | |
name: "Check version does not exists" | |
run: | | |
# Get the version from .plugin-data file. | |
VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}} | |
echo "Get Branch tag" | |
if git rev-parse "$VERSION" >/dev/null 2>&1; then | |
echo "Tag already exists, stop now"; | |
exit 1; | |
fi | |
- id: build-js | |
name: "Build project JS" | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: 'package.json' | |
- run: yarn install --frozen-lockfile | |
- run: yarn run build | |
- id: build-php | |
name: "Build project PHP" | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 7.4 | |
- run: composer install --prefer-dist --no-dev -o | |
- id: commit-and-push | |
name: "Commit and push new TAG" | |
run: | | |
# Get the version from .plugin-data file. | |
VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}} | |
echo "Copy .distignore to .gitignore" | |
cp .distignore .gitignore | |
echo "Configure git" | |
git config --local user.email "$(git log --format='%ae' HEAD^!)" | |
git config --local user.name "$(git log --format='%an' HEAD^!)" | |
echo "Creating branch" | |
git checkout -b release/${VERSION} | |
echo "Creating tag ${VERSION}" | |
git add . | |
git add -u | |
git commit -m "Release version ${VERSION}" | |
git tag ${VERSION} | |
git push --tags |