|
| 1 | +name: Plugin Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + with: |
| 17 | + fetch-depth: '0' |
| 18 | + |
| 19 | + - name: Get current version |
| 20 | + id: get_version |
| 21 | + run: | |
| 22 | + version=$(grep -oP 'Version:\s*\K[0-9.]+' github-to-wordpress-sync.php) |
| 23 | + echo "Current version: $version" |
| 24 | + echo "version=$version" >> $GITHUB_ENV |
| 25 | +
|
| 26 | + - name: Bump version if release |
| 27 | + if: contains(github.event.head_commit.message, 'release') |
| 28 | + run: | |
| 29 | + current_version=$(grep -oP 'Version:\s*\K[0-9.]+' github-to-wordpress-sync.php) |
| 30 | + next_version=$(awk -F. '{print $1 "." ($2+1)}' <<< "$current_version") |
| 31 | + sed -i "s/Version: $current_version/Version: $next_version/" github-to-wordpress-sync.php |
| 32 | + echo "new_version=$next_version" >> $GITHUB_ENV |
| 33 | +
|
| 34 | + - name: Commit version bump |
| 35 | + if: contains(github.event.head_commit.message, 'release') |
| 36 | + run: | |
| 37 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 38 | + git config --local user.name "github-actions[bot]" |
| 39 | + git add github-to-wordpress-sync.php |
| 40 | + git commit -m "Bump version to ${{ env.new_version }}" |
| 41 | + git push |
| 42 | +
|
| 43 | + - name: Create zip file |
| 44 | + run: | |
| 45 | + mkdir -p github-to-wordpress-sync |
| 46 | + rsync -av --exclude='.git' --exclude='.github' --exclude='github-to-wordpress-sync' ./ github-to-wordpress-sync/ |
| 47 | + zip -r github-to-wordpress-sync.zip github-to-wordpress-sync |
| 48 | + rm -rf github-to-wordpress-sync |
| 49 | +
|
| 50 | + - name: Create GitHub Release |
| 51 | + if: contains(github.event.head_commit.message, 'release') |
| 52 | + uses: softprops/action-gh-release@v1 |
| 53 | + with: |
| 54 | + files: github-to-wordpress-sync.zip |
| 55 | + tag_name: "v${{ env.new_version }}" |
| 56 | + name: "Release v${{ env.new_version }}" |
| 57 | + body: "Release v${{ env.new_version }} of the plugin." |
| 58 | + env: |
| 59 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Create GitHub Pre-release |
| 62 | + if: contains(github.event.head_commit.message, 'alphatag') |
| 63 | + uses: softprops/action-gh-release@v1 |
| 64 | + with: |
| 65 | + prerelease: true |
| 66 | + files: github-to-wordpress-sync.zip |
| 67 | + tag_name: "pre-v${{ env.version }}" |
| 68 | + name: "Pre-release v${{ env.version }}" |
| 69 | + body: "Pre-release v${{ env.version }} of the plugin." |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments