|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump: |
| 7 | + description: Version bump |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: [patch, minor, major] |
| 11 | + dry_run: |
| 12 | + description: Dry run (no git push, no WP.org commit) |
| 13 | + required: false |
| 14 | + type: boolean |
| 15 | + default: false |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: wordpress-org-release |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: read |
| 23 | + |
| 24 | +jobs: |
| 25 | + phpcs: |
| 26 | + if: >- |
| 27 | + github.ref == 'refs/heads/master' |
| 28 | + && ( github.actor == 'KingYes' || github.actor == 'bainternet' || github.actor == 'arielk' ) |
| 29 | + && startsWith( github.repository, 'elementor/' ) |
| 30 | + uses: ./.github/workflows/php-coding-standards.yml |
| 31 | + |
| 32 | + phpunit: |
| 33 | + if: >- |
| 34 | + github.ref == 'refs/heads/master' |
| 35 | + && ( github.actor == 'KingYes' || github.actor == 'bainternet' || github.actor == 'arielk' ) |
| 36 | + && startsWith( github.repository, 'elementor/' ) |
| 37 | + uses: ./.github/workflows/phpunit.yml |
| 38 | + |
| 39 | + release: |
| 40 | + needs: [phpcs, phpunit] |
| 41 | + runs-on: ubuntu-latest |
| 42 | + permissions: |
| 43 | + contents: write |
| 44 | + |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + with: |
| 48 | + fetch-depth: 0 |
| 49 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + |
| 51 | + - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2 |
| 52 | + with: |
| 53 | + php-version: '7.4' |
| 54 | + tools: composer:v2 |
| 55 | + |
| 56 | + - uses: actions/cache@v4 |
| 57 | + with: |
| 58 | + path: vendor |
| 59 | + key: composer-${{ hashFiles('composer.json') }} |
| 60 | + restore-keys: | |
| 61 | + composer- |
| 62 | +
|
| 63 | + - name: Install Composer dependencies |
| 64 | + run: composer install --prefer-dist --no-progress |
| 65 | + |
| 66 | + - name: Lint |
| 67 | + run: composer lint |
| 68 | + |
| 69 | + - uses: actions/setup-node@v4 |
| 70 | + with: |
| 71 | + node-version: '20' |
| 72 | + |
| 73 | + - name: Install npm dependencies |
| 74 | + run: npm install |
| 75 | + |
| 76 | + - name: Compute next version |
| 77 | + run: | |
| 78 | + VERSION=$(node scripts/next-version.js ${{ inputs.bump }}) |
| 79 | + echo "VERSION=$VERSION" >> "$GITHUB_ENV" |
| 80 | + echo "TAG=v$VERSION" >> "$GITHUB_ENV" |
| 81 | + echo "Next version: $VERSION" |
| 82 | +
|
| 83 | + - name: Validate readme changelog |
| 84 | + run: node scripts/validate-readme-changelog.js "${{ env.VERSION }}" |
| 85 | + |
| 86 | + - name: Configure git |
| 87 | + run: | |
| 88 | + git config user.name "github-actions[bot]" |
| 89 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 90 | +
|
| 91 | + - name: Bump version |
| 92 | + run: npm version ${{ inputs.bump }} --no-git-tag-version |
| 93 | + |
| 94 | + - name: Sync version to plugin files |
| 95 | + run: npm run version:sync |
| 96 | + |
| 97 | + - name: Build plugin directory |
| 98 | + run: npm run package |
| 99 | + |
| 100 | + - name: Validate build |
| 101 | + env: |
| 102 | + PLUGIN_SLUG: aryo-activity-log |
| 103 | + PLUGIN_VERSION: ${{ env.VERSION }} |
| 104 | + run: bash scripts/validate-build-files.sh |
| 105 | + |
| 106 | + - name: Create zip |
| 107 | + run: | |
| 108 | + zip -r aryo-activity-log.${{ env.VERSION }}.zip ./aryo-activity-log/* |
| 109 | +
|
| 110 | + - name: Commit version bump |
| 111 | + if: ${{ inputs.dry_run != true }} |
| 112 | + run: | |
| 113 | + git add package.json package-lock.json aryo-activity-log.php readme.txt |
| 114 | + git commit -m "Internal: Release ${{ env.VERSION }}" |
| 115 | +
|
| 116 | + - name: Create tag |
| 117 | + if: ${{ inputs.dry_run != true }} |
| 118 | + run: git tag "${{ env.TAG }}" |
| 119 | + |
| 120 | + - name: Extract changelog from readme |
| 121 | + id: changelog |
| 122 | + run: | |
| 123 | + node scripts/extract-changelog-section.js "${{ env.VERSION }}" > /tmp/changelog_section.txt |
| 124 | +
|
| 125 | + { |
| 126 | + echo "body<<EOF" |
| 127 | + echo "## Changelog" |
| 128 | + echo "" |
| 129 | + cat /tmp/changelog_section.txt |
| 130 | + echo "" |
| 131 | + echo "EOF" |
| 132 | + } >> "$GITHUB_OUTPUT" |
| 133 | +
|
| 134 | + - name: Push commit and tag |
| 135 | + if: ${{ inputs.dry_run != true }} |
| 136 | + run: | |
| 137 | + git push origin master |
| 138 | + git push origin "${{ env.TAG }}" |
| 139 | +
|
| 140 | + - name: Create GitHub Release |
| 141 | + if: ${{ inputs.dry_run != true }} |
| 142 | + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2 |
| 143 | + with: |
| 144 | + tag_name: ${{ env.TAG }} |
| 145 | + name: ${{ env.TAG }} |
| 146 | + body: ${{ steps.changelog.outputs.body }} |
| 147 | + files: aryo-activity-log.${{ env.VERSION }}.zip |
| 148 | + |
| 149 | + - name: Deploy to WordPress.org |
| 150 | + if: ${{ inputs.dry_run != true }} |
| 151 | + uses: 10up/action-wordpress-plugin-deploy@54bd289b8525fd23a5c365ec369185f2966529c2 # stable |
| 152 | + env: |
| 153 | + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
| 154 | + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
| 155 | + SLUG: aryo-activity-log |
| 156 | + VERSION: ${{ env.VERSION }} |
| 157 | + BUILD_DIR: aryo-activity-log |
| 158 | + |
| 159 | + - name: Deploy to WordPress.org (dry run) |
| 160 | + if: ${{ inputs.dry_run == true }} |
| 161 | + uses: 10up/action-wordpress-plugin-deploy@54bd289b8525fd23a5c365ec369185f2966529c2 # stable |
| 162 | + with: |
| 163 | + dry-run: true |
| 164 | + env: |
| 165 | + SLUG: aryo-activity-log |
| 166 | + VERSION: ${{ env.VERSION }} |
| 167 | + BUILD_DIR: aryo-activity-log |
| 168 | + |
| 169 | + - name: Summary |
| 170 | + run: | |
| 171 | + if [[ "${{ inputs.dry_run }}" == "true" ]]; then |
| 172 | + echo "::notice::Dry run complete for v${{ env.VERSION }}. No commits, tags, or WP.org deploys were made." |
| 173 | + else |
| 174 | + echo "::notice::Released v${{ env.VERSION }} to GitHub and WordPress.org." |
| 175 | + fi |
0 commit comments