1+ # This workflow cannot post sticky comments on PRs from forked repositories.
2+ # Instead, it outputs the message it would have posted as a workflow notice.
3+ # See https://github.com/protocol/.github/issues/254 for details.
4+
15name : Release Checker
26on : [ workflow_call ]
37
3034 read -ra arr <<< $(git diff-index ${{ github.event.pull_request.base.sha }} -- version.json)
3135 status=0
3236 git rev-list $VERSION &> /dev/null || status=$?
33- if [[ "${arr[4]}" == "A" && $status == 0 ]]; then
37+ if [[ "${arr[4]}" == "A" && $status == 0 ]]; then
3438 echo "INITIAL_RUN=true" >> $GITHUB_ENV
3539 fi
3640 - name : Install semver (node command line tool)
4145 run : semver ${{ env.VERSION }} # fails if the version is not a valid semver version (e.g. v0.1 would fail)
4246 - name : Determine version number to compare to
4347 if : env.INITIAL_RUN == 'false'
44- # We need to determine the version number we want to compare to,
48+ # We need to determine the version number we want to compare to,
4549 # taking into account that this might be a (patch) release on a release branch.
4650 # Example:
4751 # Imagine a module that has releases for v0.1.0, v0.2.0 and v0.3.0.
@@ -71,10 +75,10 @@ jobs:
7175 if : env.INITIAL_RUN == 'false' && env.COMPARETO != ''
7276 run : |
7377 # First get the diff for the go.mod file in the root directory...
74- output=$(git diff ${{ env.COMPARETO }}..${{ github.event.pull_request.head.sha }} -- './go.mod')
78+ output=$(git diff ${{ env.COMPARETO }}..HEAD -- './go.mod')
7579 # ... then get the diff for all go.mod files in subdirectories.
76- # Note that this command also finds go.mod files more than one level deep in the directory structure.
77- output+=$(git diff ${{ env.COMPARETO }}..${{ github.event.pull_request.head.sha }} -- '*/go.mod')
80+ # Note that this command also finds go.mod files more than one level deep in the directory structure.
81+ output+=$(git diff ${{ env.COMPARETO }}..HEAD -- '*/go.mod')
7882 if [[ -z "$output" ]]; then
7983 output="(empty)"
8084 fi
9094 if : env.INITIAL_RUN == 'false' && env.COMPARETO != ''
9195 run : |
9296 go install github.com/smola/gocompat/cmd/gocompat@8498b97a44792a3a6063c47014726baa63e2e669 # v0.3.0
93- output=$(gocompat compare --go1compat --git-refs="${{ env.COMPARETO }}..${{ github.event.pull_request.head.sha }} " ./... || true)
97+ output=$(gocompat compare --go1compat --git-refs="${{ env.COMPARETO }}..HEAD " ./... || true)
9498 if [[ -z "$output" ]]; then
9599 output="(empty)"
96100 fi
@@ -104,29 +108,39 @@ jobs:
104108 If you wish to cut a release once this PR is merged, please add the \`release\` label to this PR.
105109 EOF" >> $GITHUB_ENV
106110 if: github.base_ref != github.event.repository.default_branch
107- - name : Post output
108- uses : marocchino/sticky-pull-request-comment@82e7a0d3c51217201b3fedc4ddde6632e969a477 # v2.1.1
111+ - run : |
112+ echo 'MESSAGE<<EOF
113+ Suggested version: `${{ env.VERSION }}`
114+ Comparing to: [`${{ env.COMPARETO }}`](${{ github.event.pull_request.base.repo.html_url }}/releases/tag/${{ env.COMPARETO }}) ([diff](${{ github.event.pull_request.base.repo.html_url }}/compare/${{ env.COMPARETO }}..${{ github.event.pull_request.head.label }}))
115+
116+ Changes in `go.mod` file(s):
117+ ```diff
118+ ${{ env.GOMODDIFF }}
119+ ```
120+
121+ `gorelease` says:
122+ ```
123+ ${{ env.GORELEASE }}
124+ ```
125+
126+ `gocompat` says:
127+ ```
128+ ${{ env.GOCOMPAT }}
129+ ```
130+ ${{ env.RELEASE_BRANCH_NOTE }}
131+ EOF' >> $GITHUB_ENV
109132 if: env.INITIAL_RUN == 'false' && env.COMPARETO != ''
133+ - name : Post message on PR
134+ uses : marocchino/sticky-pull-request-comment@82e7a0d3c51217201b3fedc4ddde6632e969a477 # v2.1.1
135+ if : env.INITIAL_RUN == 'false' && env.COMPARETO != '' && github.event.pull_request.head.repo.full_name == github.repository
110136 with :
111137 header : release-check
112138 recreate : true
113- message : |
114- Suggested version: `${{ env.VERSION }}`
115- Comparing to: [`${{ env.COMPARETO }}`](${{ github.event.pull_request.base.repo.html_url }}/releases/tag/${{ env.COMPARETO }}) ([diff](${{ github.event.pull_request.base.repo.html_url }}/compare/${{ env.COMPARETO }}..${{ github.event.pull_request.head.ref }}))
116-
117- Changes in `go.mod` file(s):
118- ```diff
119- ${{ env.GOMODDIFF }}
120- ```
121-
122- `gorelease` says:
123- ```
124- ${{ env.GORELEASE }}
125- ```
126-
127- `gocompat` says:
128- ```
129- ${{ env.GOCOMPAT }}
130- ```
131- ${{ env.RELEASE_BRANCH_NOTE }}
132-
139+ message : ${{ env.MESSAGE }}
140+ - name : Set a notice message on run
141+ run : |
142+ message="${MESSAGE//'%'/'%25'}"
143+ message="${message//$'\n'/'%0A'}"
144+ message="${message//$'\r'/'%0D'}"
145+ echo "::notice ::$message"
146+ if : env.INITIAL_RUN == 'false' && env.COMPARETO != '' && github.event.pull_request.head.repo.full_name != github.repository
0 commit comments