|
17 | 17 | required: false |
18 | 18 |
|
19 | 19 | permissions: |
| 20 | + actions: write |
20 | 21 | contents: write |
21 | 22 | issues: write |
22 | 23 | pull-requests: write |
@@ -51,23 +52,37 @@ jobs: |
51 | 52 | echo "version=$version" >> "$GITHUB_OUTPUT" |
52 | 53 |
|
53 | 54 | - name: Create tag if missing |
| 55 | + id: create_tag |
54 | 56 | env: |
55 | 57 | PUSH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }} |
56 | 58 | TARGET_SHA: ${{ github.event.inputs.sha || github.event.pull_request.merge_commit_sha || github.sha }} |
57 | 59 | run: | |
58 | 60 | tag="v${{ steps.version.outputs.version }}" |
| 61 | + created="false" |
59 | 62 |
|
60 | 63 | git fetch --tags origin |
61 | 64 | if git rev-parse "$tag" >/dev/null 2>&1; then |
62 | 65 | echo "tag $tag already exists" |
63 | | - exit 0 |
| 66 | + else |
| 67 | + git config user.name "github-actions[bot]" |
| 68 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 69 | + git remote set-url origin "https://x-access-token:${PUSH_TOKEN}@github.com/${{ github.repository }}.git" |
| 70 | + git tag "$tag" "$TARGET_SHA" |
| 71 | + git push origin "$tag" |
| 72 | + created="true" |
64 | 73 | fi |
65 | 74 |
|
66 | | - git config user.name "github-actions[bot]" |
67 | | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
68 | | - git remote set-url origin "https://x-access-token:${PUSH_TOKEN}@github.com/${{ github.repository }}.git" |
69 | | - git tag "$tag" "$TARGET_SHA" |
70 | | - git push origin "$tag" |
| 75 | + echo "tag=$tag" >> "$GITHUB_OUTPUT" |
| 76 | + echo "created=$created" >> "$GITHUB_OUTPUT" |
| 77 | +
|
| 78 | + - name: Dispatch release workflow |
| 79 | + if: steps.create_tag.outputs.created == 'true' |
| 80 | + env: |
| 81 | + GH_TOKEN: ${{ github.token }} |
| 82 | + run: | |
| 83 | + gh workflow run release.yml \ |
| 84 | + --ref main \ |
| 85 | + -f tag="${{ steps.create_tag.outputs.tag }}" |
71 | 86 |
|
72 | 87 | - name: Mark release PR as tagged |
73 | 88 | if: github.event_name == 'pull_request_target' || github.event.inputs.pr_number != '' |
|
0 commit comments