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-latest
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-latest
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 : Install poetry
116+ run : curl -sSL https://install.python-poetry.org | python3 -
117+
118+ - name : Set Git Identity
119+ run : |
120+ git config --global user.name '${{env.BUILD_BOT}}'
121+ git config --global user.email '${{env.BUILD_BOT}}@users.noreply.github.com'
122+ env :
123+ GITHUB_TOKEN : ${{ secrets.POLYWRAP_BUILD_BOT_PAT }}
124+
125+ - name : Apply Python Version & Commit
126+ run : bash ./scripts/publishPackages.sh ${{env.RELEASE_VERSION}} __token__ ${{secrets.POLYWRAP_BUILD_BOT_PYPI_PAT}}
127+
128+ - name : Create Pull Request
129+ id : cpr
130+ uses : peter-evans/create-pull-request@v3
131+ with :
132+ token : ${{ secrets.POLYWRAP_BUILD_BOT_PAT }}
133+ push-to-fork : ${{env.RELEASE_FORKS}}/${{github.event.pull_request.base.repo.name}}
134+ branch : release/origin-${{env.RELEASE_VERSION}}
135+ base : ${{github.event.pull_request.base.ref}}
136+ committer : GitHub <noreply@github.com>
137+ author : ${{env.BUILD_BOT}} <${{env.BUILD_BOT}}@users.noreply.github.com>
138+ commit-message : " ${{env.RELEASE_VERSION}}"
139+ title : ' Python client (${{env.RELEASE_VERSION}})'
140+ body : |
141+ ## Python client (${{env.RELEASE_VERSION}})
142+
143+ ### Breaking Changes
144+
145+ - [ ] TODO
146+
147+ ### Features
148+
149+ - [ ] TODO
150+
151+ ### Bug Fixes
152+
153+ - [ ] TODO
154+
155+ - name : Release PR Created...
156+ uses : actions/github-script@0.8.0
157+ with :
158+ github-token : ${{secrets.GITHUB_TOKEN}}
159+ script : |
160+ github.issues.createComment({
161+ issue_number: context.issue.number,
162+ owner: context.repo.owner,
163+ repo: context.repo.repo,
164+ body: '**[Release PR Created](https://github.com/${{github.repository}}/pull/${{ steps.cpr.outputs.pull-request-number }}) (`${{env.RELEASE_VERSION}}`)**'
165+ })
0 commit comments