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