|
16 | 16 |
|
17 | 17 | jobs: |
18 | 18 | version: |
19 | | - runs-on: ubuntu-latest |
20 | | - outputs: |
21 | | - tag: ${{ steps.version.outputs.version }} |
22 | | - steps: |
23 | | - - name: Checkout branch for release |
24 | | - uses: actions/checkout@v4 |
25 | | - |
26 | | - - name: Get tag version from package.json |
27 | | - id: version |
28 | | - run: | |
29 | | - INPUT_VERSION=${{ github.event.inputs.version }} |
30 | | - if [ -z "$INPUT_VERSION" ]; then |
31 | | - echo "::info:: No version input provided, defaulting to 'next'." |
32 | | - INPUT_VERSION="next" |
33 | | - fi |
34 | | -
|
35 | | - if [ $INPUT_VERSION = "next" ]; then |
36 | | - CURR=$(jq -r .version package.json) |
37 | | - BRANCH_NAME="${{ github.ref_name }}" |
38 | | - |
39 | | - # Check if branch name contains "beta" |
40 | | - if [[ $BRANCH_NAME == *"beta"* ]]; then |
41 | | - # Handle beta version (e.g., 3.7.1-beta.1 -> 3.7.1-beta.2) |
42 | | - if [[ $CURR =~ ^([0-9]+\.[0-9]+\.[0-9]+-beta\.)([0-9]+)$ ]]; then |
43 | | - BASE="${BASH_REMATCH[1]}" |
44 | | - BETA_NUM="${BASH_REMATCH[2]}" |
45 | | - NEW_BETA_NUM=$((BETA_NUM+1)) |
46 | | - NEW_VERSION="${BASE}${NEW_BETA_NUM}" |
47 | | - echo "::notice::Incrementing beta version: $CURR -> $NEW_VERSION" |
48 | | - else |
49 | | - echo "::error::Branch contains 'beta' but version format is invalid: $CURR" |
50 | | - exit 1 |
51 | | - fi |
52 | | - else |
53 | | - # Handle regular version (e.g., 3.7.1 -> 3.7.2) |
54 | | - MAJOR=$(echo $CURR | cut -d. -f1) |
55 | | - MINOR=$(echo $CURR | cut -d. -f2) |
56 | | - PATCH=$(echo $CURR | cut -d. -f3) |
57 | | - NEW_PATCH=$((PATCH+1)) |
58 | | - NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH" |
59 | | - fi |
60 | | - VERSION="$NEW_VERSION" |
61 | | - else |
62 | | - VERSION="${{ github.event.inputs.version }}" |
63 | | - fi |
64 | | - |
65 | | - if [ -z "$VERSION" ]; then |
66 | | - echo "::error::Version is empty. Failing job." |
67 | | - exit 1 |
68 | | - fi |
69 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 19 | + if: github.event.inputs.version == 'next' |
| 20 | + uses: codesnippetspro/.github/.github/workflows/next_version.yml@main |
| 21 | + with: |
| 22 | + file_path: package.json |
| 23 | + ref_name: ${{ github.ref_name }} |
70 | 24 |
|
71 | 25 | changelog: |
| 26 | + if: always() |
72 | 27 | runs-on: ubuntu-latest |
73 | 28 | needs: version |
74 | | - strategy: |
75 | | - matrix: |
76 | | - include: |
77 | | - - target-file: "CHANGELOG.md" |
78 | | - template: "changelog" |
79 | | - name: "github-changelog" |
80 | | - - target-file: "src/readme.txt" |
81 | | - template: "readme" |
82 | | - name: "wordpress-readme" |
83 | 29 | steps: |
84 | 30 | - name: Validate repository access |
85 | 31 | id: validate |
@@ -118,22 +64,22 @@ jobs: |
118 | 64 | run: | |
119 | 65 | target_repo="${{ steps.validate.outputs.target_repo }}" |
120 | 66 | workflow_file="${{ steps.validate.outputs.workflow_file }}" |
| 67 | + version="${{ needs.version.outputs.version || github.event.inputs.version }}" |
121 | 68 | |
122 | | - echo "::notice::Dispatching workflow '$workflow_file' for ${{ matrix.name }}..." |
123 | | - echo " Repository: $target_repo" |
124 | | - echo " Version: ${{ needs.version.outputs.tag }}" |
125 | | - echo " Template: ${{ matrix.template }}" |
126 | | - echo " Target file: ${{ matrix.target-file }}" |
127 | | - |
| 69 | + echo "::notice::Dispatching workflow '$workflow_file' to generate changelog and readme entries..." |
| 70 | + echo " Calling repo: $target_repo" |
| 71 | + echo " Version: $version" |
| 72 | + echo " Changelog path: ${GITHUB_EVENT_INPUTS_CHANGELOG_PATH:-./CHANGELOG.md}" |
| 73 | + echo " Readme path: ${GITHUB_EVENT_INPUTS_README_PATH:-./src/readme.txt}" |
| 74 | +
|
128 | 75 | # Dispatch the workflow with required parameters |
129 | 76 | if ! gh workflow run "$workflow_file" \ |
130 | 77 | --repo "$target_repo" \ |
131 | 78 | --ref main \ |
132 | 79 | --field repo="${{ github.repository }}" \ |
133 | 80 | --field branch="${{ github.ref_name }}" \ |
134 | | - --field version="${{ needs.version.outputs.tag }}" \ |
135 | | - --field template="${{ matrix.template }}" \ |
136 | | - --field target-file="./${{ matrix.target-file }}"; then |
| 81 | + --field version="$version" \ |
| 82 | + --field readme_path="./src/readme.txt" ; then |
137 | 83 | echo "::error::Failed to dispatch workflow '$workflow_file' in $target_repo" |
138 | 84 | exit 1 |
139 | 85 | fi |
|
0 commit comments