Skip to content

Commit fe6c363

Browse files
preparing for release (#13)
* preparing for release * added changelog
1 parent e726229 commit fe6c363

11 files changed

+468
-15
lines changed

.github/workflows/changelog.yml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Copyright 2021 Agnostiq Inc.
2+
#
3+
# This file is part of Covalent.
4+
#
5+
# Licensed under the GNU Affero General Public License 3.0 (the "License").
6+
# A copy of the License may be obtained with this software package or at
7+
#
8+
# https://www.gnu.org/licenses/agpl-3.0.en.html
9+
#
10+
# Use of this file is prohibited except in compliance with the License. Any
11+
# modifications or derivative works of this file must retain this copyright
12+
# notice, and modified files must contain a notice indicating that they have
13+
# been altered from the originals.
14+
#
15+
# Covalent is distributed in the hope that it will be useful, but WITHOUT
16+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17+
# FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18+
#
19+
# Relief from the License may be granted by purchasing a commercial license.
20+
21+
name: changelog
22+
23+
on:
24+
push:
25+
branches:
26+
- develop
27+
paths-ignore:
28+
- 'CHANGELOG.md'
29+
- 'VERSION'
30+
31+
jobs:
32+
changelog:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Check out head
36+
uses: actions/checkout@v3
37+
with:
38+
token: ${{ secrets.COVALENT_OPS_BOT_TOKEN }}
39+
- name: Update version number
40+
run: |
41+
HEAD_VERSION="$(cat ./VERSION)"
42+
begin=8
43+
end=$(tail -n +$((begin+1)) ./CHANGELOG.md |
44+
grep -n -m 1 "\b${HEAD_VERSION}\b" |
45+
cut -d ':' -f 1)
46+
patch=false
47+
minor=false
48+
noupdate=false
49+
while IFS= read -r line ; do
50+
if [[ $line = *"### Added"* ]] ||
51+
[[ $line = *"### Changed"* ]] ||
52+
[[ $line = *"### Removed"* ]] ; then
53+
minor=true
54+
fi
55+
if [[ $line = *"### Fixed"* ]] ; then
56+
patch=true
57+
fi
58+
if [[ $line = *"### Tests"* ]] ||
59+
[[ $line = *"### Docs"* ]] ; then
60+
noupdate=true
61+
fi
62+
done <<< "$(tail +$begin ./CHANGELOG.md | head -$end)"
63+
IFS='.' read -ra semver <<< "$HEAD_VERSION"
64+
vmajor="${semver[0]}"
65+
vminor="${semver[1]}"
66+
vpatch="${semver[2]}"
67+
if $minor; then
68+
#increment minor version
69+
vminor="$(( vminor + 1 ))"
70+
vpatch=0
71+
elif $patch; then
72+
#increment patch version
73+
vpatch="$(( vpatch + 1 ))"
74+
elif $noupdate; then
75+
#do nothing
76+
:
77+
else
78+
echo 'Changelog does not contain enough information to update the version.'
79+
exit 1
80+
fi
81+
version="${vmajor}.${vminor}.${vpatch}"
82+
changelog_header="## [${version}] - $(date -I)"
83+
message="noop"
84+
if $minor || $patch ; then
85+
message="The new version will be $version"
86+
nl=$'\n'
87+
sed -i '/UNRELEASED/a\'$'\n''\'$'\n'"$changelog_header" CHANGELOG.md
88+
echo $version > VERSION
89+
echo $message
90+
else
91+
echo "This PR only contains updates to tests and docs. No release will be created."
92+
fi
93+
echo "MESSAGE=$message" >> $GITHUB_ENV
94+
- name: Commit
95+
if: ${{ env.MESSAGE != 'noop' }}
96+
uses: EndBug/add-and-commit@v9
97+
with:
98+
author_name: CovalentOpsBot
99+
author_email: [email protected]
100+
message: ${{ env.MESSAGE }}
101+
push: origin develop --force
102+
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2021 Agnostiq Inc.
2+
#
3+
# This file is part of Covalent.
4+
#
5+
# Licensed under the GNU Affero General Public License 3.0 (the "License").
6+
# A copy of the License may be obtained with this software package or at
7+
#
8+
# https://www.gnu.org/licenses/agpl-3.0.en.html
9+
#
10+
# Use of this file is prohibited except in compliance with the License. Any
11+
# modifications or derivative works of this file must retain this copyright
12+
# notice, and modified files must contain a notice indicating that they have
13+
# been altered from the originals.
14+
#
15+
# Covalent is distributed in the hope that it will be useful, but WITHOUT
16+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17+
# FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18+
#
19+
# Relief from the License may be granted by purchasing a commercial license.
20+
21+
on:
22+
pull_request
23+
24+
name: Changelog Reminder
25+
26+
jobs:
27+
remind:
28+
name: Changelog Reminder
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@master
32+
- name: Changelog Reminder
33+
uses: peterjgrainger/[email protected]
34+
with:
35+
changelog_regex: 'CHANGELOG.md'
36+
customPrMessage: |
37+
Hello. You may have forgotten to update the changelog!
38+
Please edit [`CHANGELOG.md`](/AgnostiqHQ/covalent-ecs-plugin/blob/main/CHANGELOG.md) with a one-to-two sentence description of the change. You may include a small working example for new features.
39+
env:
40+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/release.yml

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Copyright 2021 Agnostiq Inc.
2+
#
3+
# This file is part of Covalent.
4+
#
5+
# Licensed under the GNU Affero General Public License 3.0 (the "License").
6+
# A copy of the License may be obtained with this software package or at
7+
#
8+
# https://www.gnu.org/licenses/agpl-3.0.en.html
9+
#
10+
# Use of this file is prohibited except in compliance with the License. Any
11+
# modifications or derivative works of this file must retain this copyright
12+
# notice, and modified files must contain a notice indicating that they have
13+
# been altered from the originals.
14+
#
15+
# Covalent is distributed in the hope that it will be useful, but WITHOUT
16+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17+
# FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18+
#
19+
# Relief from the License may be granted by purchasing a commercial license.
20+
21+
name: release
22+
23+
on:
24+
workflow_dispatch:
25+
inputs:
26+
stable_version:
27+
description: "Stable version number, e.g. 0.32.3"
28+
type: string
29+
test_release:
30+
description: "Test the workflow but don't create the release. Uncheck this box to create a release."
31+
required: true
32+
type: boolean
33+
default: true
34+
workflow_call:
35+
inputs:
36+
prerelease:
37+
description: "true: Create a prerelease. false: Create a stable release"
38+
required: true
39+
type: boolean
40+
default: true
41+
42+
43+
env:
44+
PAUL_BLART: >
45+
'['
46+
'"scottwn",'
47+
'"FyzHsn",'
48+
'"wjcunningham7",'
49+
'"santoshkumarradha"]'
50+
51+
jobs:
52+
github:
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Check out release tag
56+
uses: actions/checkout@v2
57+
if: github.event.inputs.stable_version
58+
with:
59+
persist-credentials: false
60+
fetch-depth: 0
61+
ref: "v${{ github.event.inputs.stable_version }}"
62+
63+
- name: Check out master
64+
uses: actions/checkout@v2
65+
if: inputs.prerelease
66+
with:
67+
persist-credentials: false
68+
fetch-depth: 0
69+
70+
- name: Read version
71+
run: |
72+
if [ -z ${{ inputs.prerelease }} ] && \
73+
[ -z ${{ github.event.inputs.stable_version }} ] ; then
74+
echo "You can't create a stable release without specifying the stable version number."
75+
exit 1
76+
fi
77+
VERSION="$(cat ./VERSION)"
78+
echo "VERSION=$VERSION" >> $GITHUB_ENV
79+
echo "RELEASE=v$VERSION" >> $GITHUB_ENV
80+
81+
- name: Tag commit
82+
if: inputs.prerelease
83+
id: push
84+
run: |
85+
git config user.name "CovalentOpsBot"
86+
git config user.email "[email protected]"
87+
git tag -a $RELEASE -m "Release $RELEASE"
88+
git remote set-url origin https://${{ secrets.COVALENT_OPS_BOT_TOKEN }}@github.com/AgnostiqHQ/covalent-ecs-plugin.git
89+
git push origin $RELEASE
90+
91+
- name: Check conditions for stable release
92+
if: >
93+
github.event.inputs.stable_version
94+
&& contains(env.PAUL_BLART, github.actor)
95+
id: no-push
96+
run: echo "Stable release for version ${{ github.event.inputs.stable_version }}"
97+
98+
- name: Generate release message
99+
id: message
100+
run: |
101+
begin=$(grep -n "\b${VERSION}\b" ./CHANGELOG.md | cut -d ':' -f 1)
102+
previous_version=$(git describe --abbrev=0 $RELEASE^ | cut -c2-)
103+
end=$(tail -n +$((begin+1)) ./CHANGELOG.md | grep -n -m 1 "\b${previous_version}\b" | cut -d ':' -f 1)
104+
echo 'MESSAGE<<EOF' >> $GITHUB_ENV
105+
tail +$begin ./CHANGELOG.md | head -$end >> $GITHUB_ENV
106+
echo 'EOF' >> $GITHUB_ENV
107+
108+
- name: Create release
109+
if: >-
110+
${{ (steps.push.outcome == 'success' || steps.no-push.outcome == 'success')
111+
&& steps.message.outcome == 'success'
112+
&& (!github.event.inputs.test_release || github.event.inputs.test_release == 'false') }}
113+
uses: ncipollo/release-action@v1
114+
with:
115+
body: ${{ env.MESSAGE }}
116+
token: ${{ secrets.COVALENT_OPS_BOT_TOKEN }}
117+
tag: ${{ env.RELEASE }}
118+
prerelease: ${{ inputs.prerelease }}
119+
120+
pypi:
121+
runs-on: ubuntu-latest
122+
steps:
123+
- name: Check out release tag
124+
uses: actions/checkout@v2
125+
if: github.event.inputs.stable_version
126+
with:
127+
persist-credentials: false
128+
fetch-depth: 0
129+
ref: "v${{ github.event.inputs.stable_version }}"
130+
131+
- name: Check out master
132+
uses: actions/checkout@v2
133+
if: inputs.prerelease
134+
with:
135+
persist-credentials: false
136+
fetch-depth: 0
137+
138+
- name: Set up Python
139+
uses: actions/setup-python@v2
140+
with:
141+
python-version: 3.8
142+
143+
- name: Install Python dependencies
144+
run: |
145+
python -m pip install --upgrade pip
146+
pip install twine
147+
148+
- name: Build Prerelease Distribution
149+
if: inputs.prerelease
150+
id: pre-build
151+
run: python setup.py egg_info --tag-build=pre sdist
152+
153+
- name: Build Stable Distribution
154+
if: >
155+
github.event.inputs.stable_version
156+
&& contains(env.PAUL_BLART, github.actor)
157+
id: stable-build
158+
run: python setup.py sdist
159+
160+
- name: Validate Distribution
161+
id: validate
162+
run: |
163+
VERSION="$(cat ./VERSION)"
164+
if [ -z ${{ inputs.prerelease }} ] && \
165+
[ -z ${{ github.event.inputs.stable_version }} ] ; then
166+
echo "You can't create a stable release without specifying the stable version number."
167+
exit 1
168+
fi
169+
if ${{ inputs.prerelease == true }} ; then
170+
VERSION="${VERSION}rc0"
171+
fi
172+
VERSION="$(echo $VERSION | sed 's/-/.post/')"
173+
cd dist
174+
tar xzf covalent-ecs-plugin-${VERSION}.tar.gz
175+
diff -r covalent-ecs-plugin-${VERSION}/covalent_ecs_plugin ../covalent_ecs_plugin
176+
rm -rf covalent-ecs-plugin-${VERSION}/
177+
178+
- name: Upload Distribution
179+
if: >
180+
steps.pre-build.outcome == 'success'
181+
|| steps.stable-build.outcome == 'success'
182+
&& steps.validate.outcome == 'success'
183+
&& ${{ !github.event.inputs.test_release }}
184+
env:
185+
TWINE_USERNAME: __token__
186+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
187+
run: twine upload dist/*

0 commit comments

Comments
 (0)