|
9 | 9 | permissions: |
10 | 10 | id-token: write |
11 | 11 | contents: read |
| 12 | + issues: write |
12 | 13 | steps: |
13 | 14 | - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
14 | 15 | with: |
|
19 | 20 | python-version: '3.13' |
20 | 21 |
|
21 | 22 | - name: Install build tooling |
22 | | - uses: ./.github/actions/setup-hatch |
| 23 | + uses: $/.github/actions/setup-hatch |
23 | 24 |
|
24 | 25 | - name: Get Version |
25 | 26 | id: version |
|
69 | 70 | uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3 |
70 | 71 |
|
71 | 72 | - name: Set up Docker publishing |
72 | | - uses: ./.github/actions/setup-docker |
| 73 | + uses: $/.github/actions/setup-docker |
73 | 74 | with: |
74 | 75 | dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} |
75 | 76 | dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} |
@@ -123,3 +124,44 @@ jobs: |
123 | 124 | socketdev/cli:${{ env.VERSION }} |
124 | 125 | build-args: | |
125 | 126 | CLI_VERSION=${{ env.VERSION }} |
| 127 | +
|
| 128 | + # Releases are immutable, so a failed run leaves a published GitHub release whose |
| 129 | + # tag can never be reused, with nothing on PyPI or Docker Hub behind it. A failed |
| 130 | + # run only notifies whoever published the release, so raise it where the team |
| 131 | + # will see it. |
| 132 | + - name: Open an issue for the failed release |
| 133 | + if: failure() |
| 134 | + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 |
| 135 | + env: |
| 136 | + VERSION: ${{ env.VERSION }} |
| 137 | + with: |
| 138 | + script: | |
| 139 | + const release = context.payload.release; |
| 140 | + const runUrl = |
| 141 | + `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}` + |
| 142 | + `/actions/runs/${context.runId}`; |
| 143 | + const body = [ |
| 144 | + `@SocketDev/customer-engineering the release workflow for [${release.tag_name}](${release.html_url}) ` + |
| 145 | + `(published by @${release.author.login}) failed: ${runUrl}`, |
| 146 | + '', |
| 147 | + `- Tag: \`${release.tag_name}\``, |
| 148 | + `- Package version at that commit: \`${process.env.VERSION || 'unknown'}\``, |
| 149 | + '', |
| 150 | + 'Check the run for which step failed. If it failed before "Publish to PyPI", nothing reached PyPI or ' + |
| 151 | + 'Docker Hub, but the GitHub release is immutable and its tag can never be reused.', |
| 152 | + '', |
| 153 | + 'Before publishing another release:', |
| 154 | + '', |
| 155 | + '1. Edit this release\'s notes to say it was not published and name the release that replaces it.', |
| 156 | + '2. If the tag and the package version disagree, merge a PR that bumps the version to one with no ' + |
| 157 | + 'existing tag (the Version Check workflow enforces this), then publish a release whose tag matches ' + |
| 158 | + 'that version exactly. Do not pick the next tag number from the releases list.', |
| 159 | + ].join('\n'); |
| 160 | +
|
| 161 | + const created = await github.rest.issues.create({ |
| 162 | + owner: context.repo.owner, |
| 163 | + repo: context.repo.repo, |
| 164 | + title: `Release ${release.tag_name} failed`, |
| 165 | + body, |
| 166 | + }); |
| 167 | + core.error(`Release failed; opened #${created.data.number}`); |
0 commit comments