1+ name : Release-PR
2+ on :
3+ pull_request :
4+ types : [closed]
5+
6+ jobs :
7+ Pre-Check :
8+ if : |
9+ github.event.pull_request.merged &&
10+ endsWith(github.event.pull_request.title, '/workflows/release-pr') &&
11+ github.event.pull_request.user.login != 'polywrap-build-bot'
12+ runs-on : ubuntu-18.04
13+ steps :
14+ - name : Checkout
15+ uses : actions/checkout@v3
16+ with :
17+ ref : ${{github.event.pull_request.base.ref}}
18+
19+ - name : Pull-Request Creator Is Publisher?
20+ run : |
21+ exists=$(echo $(grep -Fxcs ${CREATOR} .github/PUBLISHERS))
22+ if [ "$exists" == "1" ] ; then
23+ echo IS_PUBLISHER=true >> $GITHUB_ENV
24+ else
25+ echo IS_PUBLISHER=false >> $GITHUB_ENV
26+ fi
27+ env :
28+ CREATOR : ${{github.event.pull_request.user.login}}
29+
30+ - name : Creator Is Not Publisher...
31+ if : env.IS_PUBLISHER == 'false'
32+ uses : actions/github-script@0.8.0
33+ with :
34+ github-token : ${{secrets.GITHUB_TOKEN}}
35+ script : |
36+ github.issues.createComment({
37+ issue_number: context.issue.number,
38+ owner: context.repo.owner,
39+ repo: context.repo.repo,
40+ body: '${{github.event.pull_request.user.login}} is not a PUBLISHER. Please see the .github/PUBLISHERS file...'
41+ })
42+
43+ - name : Read VERSION into env.RELEASE_VERSION
44+ run : echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV
45+
46+ - name : Tag Exists?
47+ id : tag_check
48+ shell : bash -ex {0}
49+ run : |
50+ GET_API_URL="https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}"
51+ http_status_code=$(curl -LI $GET_API_URL -o /dev/null -w '%{http_code}\n' -s \
52+ -H "Authorization: token ${GITHUB_TOKEN}")
53+ if [ "$http_status_code" -ne "404" ] ; then
54+ echo TAG_EXISTS=true >> $GITHUB_ENV
55+ else
56+ echo TAG_EXISTS=false >> $GITHUB_ENV
57+ fi
58+ env :
59+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60+
61+ - name : Release Already Exists...
62+ if : env.TAG_EXISTS == 'true'
63+ uses : actions/github-script@0.8.0
64+ with :
65+ github-token : ${{secrets.GITHUB_TOKEN}}
66+ script : |
67+ github.issues.createComment({
68+ issue_number: context.issue.number,
69+ owner: context.repo.owner,
70+ repo: context.repo.repo,
71+ body: '[Release Already Exists](https://api.github.com/repos/${{github.repository}}/git/ref/tags/${{env.RELEASE_VERSION}}) (`${{env.RELEASE_VERSION}}`)'
72+ })
73+
74+ - name : Fail If Conditions Aren't Met...
75+ if : |
76+ env.IS_PUBLISHER != 'true' ||
77+ env.TAG_EXISTS != 'false'
78+ run : exit 1
79+
80+ Release-PR :
81+ needs : Pre-Check
82+ runs-on : ubuntu-18.04
83+ steps :
84+ - name : Checkout
85+ uses : actions/checkout@v3
86+ with :
87+ ref : ${{github.event.pull_request.base.ref}}
88+
89+ - name : set env.RELEASE_FORKS to Release Forks' Organization
90+ run : echo RELEASE_FORKS=polywrap-release-forks >> $GITHUB_ENV
91+
92+ - name : Set env.BUILD_BOT to Build Bot's Username
93+ run : echo BUILD_BOT=polywrap-build-bot >> $GITHUB_ENV
94+
95+ - name : Read VERSION into env.RELEASE_VERSION
96+ run : echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV
97+
98+ - name : Building Release PR...
99+ uses : actions/github-script@0.8.0
100+ with :
101+ github-token : ${{secrets.GITHUB_TOKEN}}
102+ script : |
103+ github.issues.createComment({
104+ issue_number: context.issue.number,
105+ owner: context.repo.owner,
106+ repo: context.repo.repo,
107+ body: '[Building Release PR](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}) (`${{env.RELEASE_VERSION}}`)'
108+ })
109+
110+ - name : Set up Python 3.10
111+ uses : actions/setup-python@v4
112+ with :
113+ python-version : " 3.10"
114+
115+ - name : Set Git Identity
116+ run : |
117+ git config --global user.name '${{env.BUILD_BOT}}'
118+ git config --global user.email '${{env.BUILD_BOT}}@users.noreply.github.com'
119+ env :
120+ GITHUB_TOKEN : ${{ secrets.POLYWRAP_BUILD_BOT_PAT }}
121+
122+ - name : Apply Python Version & Commit
123+ run : bash ./scripts/patchVersion.sh ${{env.RELEASE_VERSION}}
124+
125+ - name : Create Pull Request
126+ id : cpr
127+ uses : peter-evans/create-pull-request@v3
128+ with :
129+ token : ${{ secrets.POLYWRAP_BUILD_BOT_PAT }}
130+ push-to-fork : ${{env.RELEASE_FORKS}}/${{github.event.pull_request.base.repo.name}}
131+ branch : release/origin-${{env.RELEASE_VERSION}}
132+ base : ${{github.event.pull_request.base.ref}}
133+ committer : GitHub <noreply@github.com>
134+ author : ${{env.BUILD_BOT}} <${{env.BUILD_BOT}}@users.noreply.github.com>
135+ commit-message : " ${{env.RELEASE_VERSION}}"
136+ title : ' polywrap-msgpack (${{env.RELEASE_VERSION}})'
137+ body : |
138+ ## polywrap-msgpack (${{env.RELEASE_VERSION}})
139+
140+ ### Breaking Changes
141+
142+ - [ ] TODO
143+
144+ ### Features
145+
146+ - [ ] TODO
147+
148+ ### Bug Fixes
149+
150+ - [ ] TODO
151+
152+ - name : Release PR Created...
153+ uses : actions/github-script@0.8.0
154+ with :
155+ github-token : ${{secrets.GITHUB_TOKEN}}
156+ script : |
157+ github.issues.createComment({
158+ issue_number: context.issue.number,
159+ owner: context.repo.owner,
160+ repo: context.repo.repo,
161+ body: '**[Release PR Created](https://github.com/${{github.repository}}/pull/${{ steps.cpr.outputs.pull-request-number }}) (`${{env.RELEASE_VERSION}}`)**'
162+ })
0 commit comments