|
11 | 11 | # |
12 | 12 | # 1. A "latest release branch" |
13 | 13 | # - Example: `release/202405` |
14 | | -# - Config file: `release-draft-config-n.yml` and `release-draft-config-n-dev.yml` |
| 14 | +# - Config file: `release-draft-config-n.yml` |
15 | 15 | # 2. A "previous release branch" |
16 | 16 | # - Example: `release/202311` |
17 | | -# - Config file: `release-draft-config-n-1.yml` and `release-draft-config-n-1-dev.yml` |
| 17 | +# - Config file: `release-draft-config-n-1.yml` |
18 | 18 | # 3. A "main branch" |
19 | 19 | # - Example: `main` |
20 | 20 | # - Config file: `release-draft-config.yml` |
@@ -72,135 +72,31 @@ jobs: |
72 | 72 | run: | |
73 | 73 | fileContent=$(cat "${FILE_PATH}") |
74 | 74 | latestMuReleaseBranch=$(echo "$fileContent" | grep -oP '(?<=latest_mu_release_branch = ").*(?=")') |
75 | | - latestMuDevBranch=$(echo "$latestMuReleaseBranch" | sed 's/release/dev/') |
76 | 75 | previousMuReleaseBranch=$(echo "$fileContent" | grep -oP '(?<=previous_mu_release_branch = ").*(?=")') |
77 | | - previousMuDevBranch=$(echo "$previousMuReleaseBranch" | sed 's/release/dev/') |
78 | | - echo "latest_mu_release_branch=${latestMuReleaseBranch}" >> $GITHUB_ENV |
79 | | - echo "latest_mu_dev_branch=${latestMuDevBranch}" >> $GITHUB_ENV |
80 | | - echo "latest_mu_dev_branch_full=refs/heads/${latestMuDevBranch}" >> $GITHUB_ENV |
81 | | - echo "latest_mu_release_branch_full=refs/heads/${latestMuReleaseBranch}" >> $GITHUB_ENV |
82 | | - echo "previous_mu_release_branch=${previousMuReleaseBranch}" >> $GITHUB_ENV |
83 | | - echo "previous_mu_dev_branch=${previousMuDevBranch}" >> $GITHUB_ENV |
84 | | - echo "previous_mu_dev_branch_full=refs/heads/${previousMuDevBranch}" >> $GITHUB_ENV |
85 | | - echo "previous_mu_release_branch_full=refs/heads/${previousMuReleaseBranch}" >> $GITHUB_ENV |
86 | | - - name: Build a ${{ env.latest_mu_release_branch }} Draft |
87 | | - if: ${{ startsWith(github.ref, env.latest_mu_dev_branch_full) }} |
| 76 | + echo "latest_mu_branch=${latestMuReleaseBranch}" >> $GITHUB_ENV |
| 77 | + echo "latest_mu_branch_full=refs/heads/${latestMuReleaseBranch}" >> $GITHUB_ENV |
| 78 | + echo "previous_mu_branch=${previousMuReleaseBranch}" >> $GITHUB_ENV |
| 79 | + echo "previous_mu_branch_full=refs/heads/${previousMuReleaseBranch}" >> $GITHUB_ENV |
| 80 | + - name: Build a ${{ env.latest_mu_branch }} Draft |
| 81 | + if: ${{ startsWith(github.ref, env.latest_mu_branch_full) }} |
88 | 82 | id: update_draft_n |
89 | 83 | uses: release-drafter/[email protected] |
90 | 84 | with: |
91 | 85 | # Note: Path is relative to .github/ |
92 | 86 | config-name: release-draft-config-n.yml |
93 | 87 | env: |
94 | 88 | GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
95 | | - - name: Draft Release for Current (${{ env.latest_mu_release_branch }}) Release Branch |
96 | | - if: steps.update_draft_n.outcome == 'success' |
97 | | - run: | |
98 | | - # Prepare the release body |
99 | | - release_body_path="${{ runner.temp }}/release_body.txt" |
100 | | - release_body=$(cat <<'EOF' |
101 | | - ${{ steps.update_draft_n.outputs.body }} |
102 | | - EOF |
103 | | - ) |
104 | | - release_body="${release_body//\`/\\\`}" |
105 | | - echo "${release_body}" > $release_body_path |
106 | | - sed -i 's/\\`/`/g' $release_body_path |
107 | | - sed -i '/\**Full Changelog\**:/d' $release_body_path |
108 | | -
|
109 | | - # Get the new tag and title |
110 | | - new_tag=$(echo "${{ steps.update_draft_n.outputs.tag_name }}" | sed 's/dev-//') |
111 | | - new_title=$(echo "${{ steps.update_draft_n.outputs.tag_name }}" | sed 's/dev/release/') |
112 | | -
|
113 | | - # Determine the corresponding tag names |
114 | | - existing_tag_prefix="" |
115 | | - tag_regex="v([0-9]{6}).*\." |
116 | | - if [[ $new_tag =~ $tag_regex ]]; then |
117 | | - existing_tag_prefix="${BASH_REMATCH[1]}" |
118 | | - fi |
119 | | -
|
120 | | - # Delete the template dev draft created |
121 | | - gh release delete "${{ steps.update_draft_n.outputs.tag_name }}" --repo ${{ github.repository }} --yes |
122 | | -
|
123 | | - # Delete any existing draft releases for this release branch |
124 | | - for tag in $(gh release list --repo ${{ github.repository }} --json tagName,isPrerelease,isDraft --jq ".[] | select(.isDraft == true and .isPrerelease == false and (.tagName | startswith(\"v$existing_tag_prefix\"))) | .tagName"); do |
125 | | - gh release delete "$tag" --repo ${{ github.repository }} --yes |
126 | | - done |
127 | | -
|
128 | | - gh release create "$new_tag" \ |
129 | | - --repo "${{ github.repository }}" \ |
130 | | - --target "${{ env.latest_mu_release_branch_full }}" \ |
131 | | - --title "$new_title" \ |
132 | | - --notes-file "$release_body_path" \ |
133 | | - --draft |
134 | | - env: |
135 | | - GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
136 | | - - name: Build a ${{ env.previous_mu_release_branch }} Draft |
137 | | - if: ${{ startsWith(github.ref, env.previous_mu_dev_branch_full) }} |
| 89 | + - name: Build a ${{ env.previous_mu_branch }} Draft |
| 90 | + if: ${{ startsWith(github.ref, env.previous_mu_branch_full) }} |
138 | 91 | id: update_draft_n_1 |
139 | 92 | uses: release-drafter/[email protected] |
140 | 93 | with: |
141 | 94 | # Note: Path is relative to .github/ |
142 | 95 | config-name: release-draft-config-n-1.yml |
143 | 96 | env: |
144 | 97 | GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
145 | | - - name: Draft Release for N-1 (${{ env.previous_mu_release_branch }}) Release Branch |
146 | | - if: steps.update_draft_n_1.outcome == 'success' |
147 | | - run: | |
148 | | - # Prepare the release body |
149 | | - release_body_path="${{ runner.temp }}/release_body.txt" |
150 | | - release_body=$(cat <<'EOF' |
151 | | - ${{ steps.update_draft_n_1.outputs.body }} |
152 | | - EOF |
153 | | - ) |
154 | | - release_body="${release_body//\`/\\\`}" |
155 | | - echo "${release_body}" > $release_body_path |
156 | | - sed -i 's/\\`/`/g' $release_body_path |
157 | | - sed -i '/\**Full Changelog\**:/d' $release_body_path |
158 | | -
|
159 | | - # Get the new tag and title |
160 | | - new_tag=$(echo "${{ steps.update_draft_n_1.outputs.tag_name }}" | sed 's/dev-//') |
161 | | - new_title=$(echo "${{ steps.update_draft_n_1.outputs.tag_name }}" | sed 's/dev/release/') |
162 | | -
|
163 | | - # Determine the corresponding tag names |
164 | | - existing_tag_prefix="" |
165 | | - tag_regex="v([0-9]{6}).*\." |
166 | | - if [[ $new_tag =~ $tag_regex ]]; then |
167 | | - existing_tag_prefix="${BASH_REMATCH[1]}" |
168 | | - fi |
169 | | -
|
170 | | - # Delete the template dev draft created |
171 | | - gh release delete "${{ steps.update_draft_n_1.outputs.tag_name }}" --repo ${{ github.repository }} --yes |
172 | | -
|
173 | | - # Delete any existing draft releases for this release branch |
174 | | - for tag in $(gh release list --repo ${{ github.repository }} --json tagName,isPrerelease,isDraft --jq ".[] | select(.isDraft == true and .isPrerelease == false and (.tagName | startswith(\"v$existing_tag_prefix\"))) | .tagName"); do |
175 | | - gh release delete "$tag" --repo ${{ github.repository }} --yes |
176 | | - done |
177 | | -
|
178 | | - gh release create "$new_tag" \ |
179 | | - --repo "${{ github.repository }}" \ |
180 | | - --target "${{ env.previous_mu_release_branch_full }}" \ |
181 | | - --title "$new_title" \ |
182 | | - --notes-file "$release_body_path" \ |
183 | | - --draft |
184 | | - env: |
185 | | - GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
186 | | - - name: Create the ${{ env.latest_mu_dev_branch }} Draft |
187 | | - if: ${{ startsWith(github.ref, env.latest_mu_dev_branch_full) }} |
188 | | - uses: release-drafter/[email protected] |
189 | | - with: |
190 | | - # Note: Path is relative to .github/ |
191 | | - config-name: release-draft-config-n-dev.yml |
192 | | - env: |
193 | | - GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
194 | | - - name: Create the ${{ env.previous_mu_dev_branch }} Draft |
195 | | - if: ${{ startsWith(github.ref, env.previous_mu_dev_branch_full) }} |
196 | | - uses: release-drafter/[email protected] |
197 | | - with: |
198 | | - # Note: Path is relative to .github/ |
199 | | - config-name: release-draft-config-n-1-dev.yml |
200 | | - env: |
201 | | - GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
202 | 98 | - name: Build the New Release Draft |
203 | | - if: ${{ !startsWith(github.ref, 'refs/heads/release') && !startsWith(github.ref, 'refs/heads/dev') }} |
| 99 | + if: ${{ !startsWith(github.ref, 'refs/heads/release') }} |
204 | 100 | id: update_draft_non_release |
205 | 101 | uses: release-drafter/[email protected] |
206 | 102 | with: |
|
0 commit comments