|
| 1 | +name: "Release new TAG" |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-and-release: |
| 12 | + name: "Release new TAG" |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v7 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + fetch-tags: true |
| 20 | + |
| 21 | + - name: Fetch tags |
| 22 | + run: git fetch --tags --prune origin |
| 23 | + |
| 24 | + - id: set-vars |
| 25 | + name: "Set variable from .plugin-data file" |
| 26 | + run: | |
| 27 | + { |
| 28 | + echo 'pluginData<<EOF' |
| 29 | + cat ./.plugin-data |
| 30 | + echo 'EOF' |
| 31 | + } >> "$GITHUB_OUTPUT" |
| 32 | +
|
| 33 | + - id: check-version |
| 34 | + name: "Check version does not exists" |
| 35 | + run: | |
| 36 | + # Get the version from .plugin-data file. |
| 37 | + VERSION=${{ fromJson(steps.set-vars.outputs.pluginData).version }} |
| 38 | +
|
| 39 | + echo "Get Branch tag" |
| 40 | + if git rev-parse "$VERSION" >/dev/null 2>&1; then |
| 41 | + echo "Tag already exists, stop now"; |
| 42 | + exit 1; |
| 43 | + fi |
| 44 | +
|
| 45 | + if git ls-remote --exit-code --tags origin "refs/tags/${VERSION}" >/dev/null 2>&1; then |
| 46 | + echo "Remote tag already exists, stop now"; |
| 47 | + exit 1; |
| 48 | + fi |
| 49 | +
|
| 50 | + - id: build-node |
| 51 | + name: Setup NodeJS |
| 52 | + uses: actions/setup-node@v7 |
| 53 | + with: |
| 54 | + node-version-file: 'package.json' |
| 55 | + cache: 'npm' |
| 56 | + - run: npm ci |
| 57 | + - run: npm run build |
| 58 | + |
| 59 | + - id: build-php |
| 60 | + name: "Build project PHP" |
| 61 | + uses: shivammathur/setup-php@v2 |
| 62 | + with: |
| 63 | + php-version: 8.1 |
| 64 | + - run: composer install --prefer-dist --no-dev -o --ignore-platform-reqs |
| 65 | + |
| 66 | + - id: commit-and-push |
| 67 | + name: "Commit and push new TAG" |
| 68 | + run: | |
| 69 | + # Get the version from .plugin-data file. |
| 70 | + VERSION=${{ fromJson(steps.set-vars.outputs.pluginData).version }} |
| 71 | +
|
| 72 | + echo "Copy .distignore to .gitignore" |
| 73 | + cp .distignore .gitignore |
| 74 | +
|
| 75 | + echo "Configure git" |
| 76 | + git config --local user.email "$(git log --format='%ae' HEAD^!)" |
| 77 | + git config --local user.name "$(git log --format='%an' HEAD^!)" |
| 78 | +
|
| 79 | + echo "Creating branch" |
| 80 | + git checkout -b "release/${VERSION}" |
| 81 | +
|
| 82 | + echo "Creating tag ${VERSION}" |
| 83 | + git add . |
| 84 | + git add -u |
| 85 | + git commit -m "Release version ${VERSION}" |
| 86 | + git tag ${VERSION} |
| 87 | + git push --tags |
0 commit comments