|
| 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 | +
|
| 41 | + - id: build-node |
| 42 | + name: "Build project CSS and JS" |
| 43 | + uses: actions/setup-node@v3 |
| 44 | + with: |
| 45 | + node-version: 16 |
| 46 | + cache: 'npm' |
| 47 | + - run: npm install |
| 48 | + - run: npm run build |
| 49 | + |
| 50 | + - id: build-php |
| 51 | + name: "Build project PHP" |
| 52 | + uses: shivammathur/setup-php@v2 |
| 53 | + with: |
| 54 | + php-version: 7.2 |
| 55 | + - run: composer install --prefer-dist --no-dev -o --ignore-platform-reqs |
| 56 | + |
| 57 | + - id: commit-and-push |
| 58 | + name: "Commit and push new TAG" |
| 59 | + run: | |
| 60 | + # Get the version from .plugin-data file. |
| 61 | + VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}} |
| 62 | +
|
| 63 | + echo "Copy .distignore to .gitignore" |
| 64 | + cp .distignore .gitignore |
| 65 | +
|
| 66 | + echo "Configure git" |
| 67 | + git config --local user.email "$(git log --format='%ae' HEAD^!)" |
| 68 | + git config --local user.name "$(git log --format='%an' HEAD^!)" |
| 69 | +
|
| 70 | + echo "Creating branch" |
| 71 | + git checkout -b release/${VERSION} |
| 72 | +
|
| 73 | + echo "Creating tag ${VERSION}" |
| 74 | + git add . |
| 75 | + git add -u |
| 76 | + git commit -m "Release version ${VERSION}" |
| 77 | + git tag ${VERSION} |
| 78 | + git push --tags |
0 commit comments