Skip to content

Commit 8ee5da3

Browse files
committed
Revert "chore: remove global versioning from workflows (#223)"
This reverts commit 37f90b1.
1 parent 4755da5 commit 8ee5da3

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

.github/workflows/cd.yaml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,41 @@ jobs:
4141
body: '${{github.event.pull_request.user.login}} is not a PUBLISHER. Please see the .github/PUBLISHERS file...'
4242
})
4343
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+
4475
- name: Fail If Conditions Aren't Met...
4576
if: |
46-
env.IS_PUBLISHER != 'true'
77+
env.IS_PUBLISHER != 'true' ||
78+
env.TAG_EXISTS != 'false'
4779
run: exit 1
4880

4981
CD:
@@ -123,3 +155,24 @@ jobs:
123155
repo: context.repo.repo,
124156
body: '**[Release PR Created](https://github.com/${{github.repository}}/pull/${{ steps.cpr-cd.outputs.pull-request-number }}) (`${{env.RELEASE_VERSION}}`)**'
125157
})
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

Comments
 (0)