|
12 | 12 | actions: read |
13 | 13 |
|
14 | 14 | steps: |
15 | | - - uses: actions/checkout@v4 |
| 15 | + - uses: actions/checkout@v5 |
16 | 16 |
|
17 | 17 | # Prepare a folder named exactly like the repo as the plugin root. |
18 | 18 | # If the repo already has such a folder (common for WP plugins), use it. |
|
45 | 45 | PLUGIN_FILE="${{ steps.prep.outputs.PKG_DIR }}/${{ github.event.repository.name }}.php" |
46 | 46 | PR_NUMBER="${{ github.event.number }}" |
47 | 47 |
|
48 | | - # Extract current version and add PR number |
| 48 | + # Extract current version |
49 | 49 | CURRENT_VERSION=$(grep -o "Version:[[:space:]]*[0-9.]*" "$PLUGIN_FILE" | sed 's/Version:[[:space:]]*//') |
50 | | - NEW_VERSION="${CURRENT_VERSION} - PR ${PR_NUMBER}" |
| 50 | +
|
| 51 | + # Increment patch version if it exists, otherwise increment minor version |
| 52 | + # Handle versions like 2.1.5 or 2.1 |
| 53 | + if [[ "$CURRENT_VERSION" =~ ^([0-9]+)\.([0-9]+)(\.([0-9]+))?$ ]]; then |
| 54 | + MAJOR="${BASH_REMATCH[1]}" |
| 55 | + MINOR="${BASH_REMATCH[2]}" |
| 56 | + PATCH="${BASH_REMATCH[4]}" |
| 57 | +
|
| 58 | + # Build new version with 'b' suffix |
| 59 | + if [ -n "$PATCH" ]; then |
| 60 | + # If patch exists, increment patch by 1 |
| 61 | + PATCH=$((PATCH + 1)) |
| 62 | + NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}b - PR ${PR_NUMBER}" |
| 63 | + else |
| 64 | + # If no patch, increment minor by 1 |
| 65 | + MINOR=$((MINOR + 1)) |
| 66 | + NEW_VERSION="${MAJOR}.${MINOR}b - PR ${PR_NUMBER}" |
| 67 | + fi |
| 68 | + else |
| 69 | + # Fallback: if version format is unexpected, just add .1 and 'b' |
| 70 | + NEW_VERSION="${CURRENT_VERSION}.1b - PR ${PR_NUMBER}" |
| 71 | + fi |
51 | 72 |
|
52 | 73 | # Replace the version line |
53 | 74 | sed -i "s/Version:[[:space:]]*[0-9.]*/Version: ${NEW_VERSION}/" "$PLUGIN_FILE" |
|
76 | 97 | # Upload the FOLDER (not a .zip). The artifact service zips it for us, |
77 | 98 | # keeping the top-level folder name inside the archive. |
78 | 99 | - name: Upload plugin artifact |
79 | | - uses: actions/upload-artifact@v4 |
| 100 | + uses: actions/upload-artifact@v5 |
80 | 101 | with: |
81 | 102 | name: ${{ github.event.repository.name }} |
82 | 103 | path: ${{ steps.prep.outputs.PKG_DIR }} |
|
0 commit comments