|
27 | 27 | - name: Install uv |
28 | 28 | uses: astral-sh/setup-uv@v10.0.1 |
29 | 29 |
|
| 30 | + - name: Resolve template version |
| 31 | + id: version |
| 32 | + env: |
| 33 | + # The Release workflow creates the release with GITHUB_TOKEN, and |
| 34 | + # GitHub does not start workflow runs from events raised by that |
| 35 | + # token, so the release trigger only fires for a release published by |
| 36 | + # hand. A tag push has no release context and must name itself. |
| 37 | + RELEASE_TAG: ${{ github.event.release.tag_name }} |
| 38 | + REF_TYPE: ${{ github.ref_type }} |
| 39 | + REF_NAME: ${{ github.ref_name }} |
| 40 | + RUN_NUMBER: ${{ github.run_number }} |
| 41 | + SERVER_URL: ${{ github.server_url }} |
| 42 | + REPOSITORY: ${{ github.repository }} |
| 43 | + run: | |
| 44 | + if [ -n "${RELEASE_TAG}" ]; then |
| 45 | + version="${RELEASE_TAG}" |
| 46 | + elif [ "${REF_TYPE}" = "tag" ]; then |
| 47 | + version="${REF_NAME}" |
| 48 | + else |
| 49 | + version="latest" |
| 50 | + fi |
| 51 | + echo "value=${version}" >> "$GITHUB_OUTPUT" |
| 52 | + # A manual run has no version to name its branch after, so fall back |
| 53 | + # to the run number to keep branches from colliding, and link no |
| 54 | + # release notes because there is no release to point at. |
| 55 | + if [ "${version}" = "latest" ]; then |
| 56 | + echo "slug=${RUN_NUMBER}" >> "$GITHUB_OUTPUT" |
| 57 | + else |
| 58 | + echo "slug=${version}" >> "$GITHUB_OUTPUT" |
| 59 | + echo "release_url=${SERVER_URL}/${REPOSITORY}/releases/tag/${version}" >> "$GITHUB_OUTPUT" |
| 60 | + fi |
| 61 | +
|
30 | 62 | - name: Update template in child repository |
31 | 63 | id: update |
32 | 64 | working-directory: child-repo |
@@ -78,17 +110,17 @@ jobs: |
78 | 110 | token: ${{ secrets.CHILD_REPO_TOKEN }} |
79 | 111 | path: child-repo |
80 | 112 | commit-message: | |
81 | | - Update template to version ${{ github.event.release.tag_name || 'latest' }} |
82 | | - title: "Update template to version ${{ github.event.release.tag_name || 'latest' }}${{ steps.update.outputs.conflicts == 'true' && ' (resolve conflicts)' || '' }}" |
| 113 | + Update template to version ${{ steps.version.outputs.value }} |
| 114 | + title: "Update template to version ${{ steps.version.outputs.value }}${{ steps.update.outputs.conflicts == 'true' && ' (resolve conflicts)' || '' }}" |
83 | 115 | body: | |
84 | 116 | ## Template Update |
85 | 117 |
|
86 | | - This PR updates the project template to version `${{ github.event.release.tag_name || 'latest' }}`. |
| 118 | + This PR updates the project template to version `${{ steps.version.outputs.value }}`. |
87 | 119 |
|
88 | 120 | ### Changes |
89 | 121 | - Updated from template: ${{ github.repository }} |
90 | | - - Template version: ${{ github.event.release.tag_name || 'latest' }} |
91 | | - ${{ github.event.release.html_url && format('- Release notes: {0}', github.event.release.html_url) || '' }} |
| 122 | + - Template version: ${{ steps.version.outputs.value }} |
| 123 | + ${{ steps.version.outputs.release_url && format('- Release notes: {0}', steps.version.outputs.release_url) || '' }} |
92 | 124 |
|
93 | 125 | ${{ steps.update.outputs.conflict_note }} |
94 | 126 |
|
|
97 | 129 |
|
98 | 130 | --- |
99 | 131 | *This PR was automatically created by the template update workflow.* |
100 | | - branch: template-update-${{ github.event.release.tag_name || github.run_number }} |
| 132 | + branch: template-update-${{ steps.version.outputs.slug }} |
101 | 133 | delete-branch: true |
0 commit comments