Skip to content

Commit 35cac3d

Browse files
authored
Merge pull request #62 from polywrap/dev
Prep 0.1.0a2 | /workflows/release-pr
2 parents 10dc699 + 05c178a commit 35cac3d

File tree

8 files changed

+1549
-1083
lines changed

8 files changed

+1549
-1083
lines changed

.github/workflows/cd.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CD
2+
on:
3+
# When Pull Request is merged
4+
pull_request_target:
5+
types: [closed]
6+
7+
jobs:
8+
getPackages:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
matrix: ${{ env.matrix }}
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
- id: set-matrix
16+
run: echo "matrix=$(./scripts/getPackages.sh)" >> $GITHUB_ENV
17+
Publish:
18+
name: Publish python packages to pypi
19+
needs:
20+
- getPackages
21+
strategy:
22+
matrix: ${{fromJSON(needs.getPackages.outputs.matrix)}}
23+
if: |
24+
github.event.pull_request.user.login == 'polywrap-build-bot' &&
25+
github.event.pull_request.merged == true
26+
runs-on: ubuntu-18.04
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v3
30+
with:
31+
ref: ${{ github.event.pull_request.base.ref }}
32+
33+
- name: Read VERSION into env.RELEASE_VERSION
34+
run: echo RELEASE_VERSION=$(cat VERSION) >> $GITHUB_ENV
35+
36+
- name: Is Pre-Release
37+
run: |
38+
STR="${RELEASE_VERSION}"
39+
SUB='pre.'
40+
if [[ "$STR" == *"$SUB"* ]]; then
41+
echo PRE_RELEASE=true >> $GITHUB_ENV
42+
else
43+
echo PRE_RELEASE=false >> $GITHUB_ENV
44+
fi
45+
- name: Set up Python 3.10
46+
uses: actions/setup-python@v4
47+
with:
48+
python-version: "3.10"
49+
50+
- name: Install python packages
51+
run: poetry install
52+
working-directory: ./packages/${{ matrix.package }}
53+
54+
- name: Publish python package to pypi
55+
run: poetry publish --build --username __token__ --password ${{secrets.POLYWRAP_BUILD_BOT_PYPI_PAT}}
56+
working-directory: ./packages/${{ matrix.package }}
57+
58+
- uses: actions/github-script@0.8.0
59+
with:
60+
github-token: ${{secrets.GITHUB_TOKEN}}
61+
script: |
62+
github.issues.createComment({
63+
issue_number: context.issue.number,
64+
owner: context.repo.owner,
65+
repo: context.repo.repo,
66+
body: '**[NPM Release Published](https://www.npmjs.com/search?q=polywrap) `${{env.RELEASE_VERSION}}`** 🎉'
67+
})

.github/workflows/ci.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
name: Python package
2-
1+
name: CI
32
on:
43
push:
54
branches:
@@ -29,7 +28,7 @@ jobs:
2928
steps:
3029
- name: Checkout repository
3130
uses: actions/checkout@v3
32-
- name: Set up Python ${{ matrix.python-version }}
31+
- name: Set up Python 3.10
3332
uses: actions/setup-python@v4
3433
with:
3534
python-version: "3.10"

.github/workflows/release-pr.yaml

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
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+
})

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0a2

0 commit comments

Comments
 (0)