Skip to content

release

release #4

Workflow file for this run

# 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-ecs-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-ecs-plugin-${VERSION}.tar.gz
diff -r covalent-ecs-plugin-${VERSION}/covalent_ecs_plugin ../covalent_ecs_plugin
rm -rf covalent-ecs-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/*