|
41 | 41 | body: '${{github.event.pull_request.user.login}} is not a PUBLISHER. Please see the .github/PUBLISHERS file...' |
42 | 42 | }) |
43 | 43 |
|
| 44 | + - name: Read VERSION into env.RELEASE_VERSION |
| 45 | + run: echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV |
| 46 | + |
| 47 | + - name: Tag Exists? |
| 48 | + id: tag_check |
| 49 | + shell: bash -ex {0} |
| 50 | + run: | |
| 51 | + GET_API_URL="https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}" |
| 52 | + http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \ |
| 53 | + -H "Authorization: token ${GITHUB_TOKEN}") |
| 54 | + if [ "$http_status_code" -ne "404" ] ; then |
| 55 | + echo TAG_EXISTS=true >> $GITHUB_ENV |
| 56 | + else |
| 57 | + echo TAG_EXISTS=false >> $GITHUB_ENV |
| 58 | + fi |
| 59 | + env: |
| 60 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 61 | + |
| 62 | + - name: Release Already Exists... |
| 63 | + if: env.TAG_EXISTS == 'true' |
| 64 | + uses: actions/github-script@0.8.0 |
| 65 | + with: |
| 66 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 67 | + script: | |
| 68 | + github.issues.createComment({ |
| 69 | + issue_number: context.issue.number, |
| 70 | + owner: context.repo.owner, |
| 71 | + repo: context.repo.repo, |
| 72 | + body: '[Release Already Exists](https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}) (`${{env.RELEASE_VERSION}}`)' |
| 73 | + }) |
| 74 | +
|
44 | 75 | - name: Fail If Conditions Aren't Met... |
45 | 76 | if: | |
46 | | - env.IS_PUBLISHER != 'true' |
| 77 | + env.IS_PUBLISHER != 'true' || |
| 78 | + env.TAG_EXISTS != 'false' |
47 | 79 | run: exit 1 |
48 | 80 |
|
49 | 81 | CD: |
@@ -123,3 +155,24 @@ jobs: |
123 | 155 | repo: context.repo.repo, |
124 | 156 | body: '**[Release PR Created](https://github.com/${{github.repository}}/pull/${{ steps.cpr-cd.outputs.pull-request-number }}) (`${{env.RELEASE_VERSION}}`)**' |
125 | 157 | }) |
| 158 | +
|
| 159 | + - id: changelog |
| 160 | + name: "Generate release changelog" |
| 161 | + uses: heinrichreimer/github-changelog-generator-action@v2.3 |
| 162 | + with: |
| 163 | + unreleasedOnly: true |
| 164 | + unreleasedLabel: ${{ env.RELEASE_VERSION }} |
| 165 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 166 | + continue-on-error: true |
| 167 | + |
| 168 | + - name: Create GitHub Release |
| 169 | + id: create_release |
| 170 | + uses: actions/create-release@v1 |
| 171 | + env: |
| 172 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 173 | + with: |
| 174 | + tag_name: ${{ env.RELEASE_VERSION }} |
| 175 | + release_name: Release ${{ env.RELEASE_VERSION }} |
| 176 | + body: ${{ steps.changelog.outputs.changelog }} |
| 177 | + draft: true |
| 178 | + prerelease: true |
0 commit comments