Add control example #75
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check version | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Get previous pykoop version | |
id: latest_version | |
uses: Bruce17/ghaction-package-latest-version@v1 | |
with: | |
package: pykoop | |
language: python | |
# RegEx adapted from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string | |
- name: Get setup.py version | |
run: echo "setup_py_version=`grep -Po "version='\K(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?" setup.py`" >> $GITHUB_ENV | |
- name: Get CITATION.cff version | |
run: echo "citation_cff_version=`grep -Po "version\:\ v\K(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?" CITATION.cff`" >> $GITHUB_ENV | |
- name: Get README.rst version | |
run: echo "readme_rst_version=`grep -Po "version\ =\ \{\{v\K(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?" README.rst`" >> $GITHUB_ENV | |
- name: Print versions | |
run: | | |
echo "setup.py version is ${{ env.setup_py_version }}" | |
echo "CITATION.cff version is ${{ env.citation_cff_version }}" | |
echo "README.rst version is ${{ env.readme_rst_version }}" | |
echo "Latest PyPi version is ${{ steps.latest_version.outputs.latestVersion }}" | |
- name: Fail if versions do not match | |
if: ${{ (env.setup_py_version != env.citation_cff_version) || | |
(env.citation_cff_version != env.readme_rst_version) || | |
(env.readme_rst_version != env.setup_py_version) }} | |
run: | | |
echo "Version numbers in source are not consistent." | |
exit 1 | |
- name: Fail if any versions have not been updated | |
if: ${{ (env.setup_py_version == steps.latest_version.outputs.latestVersion) || | |
(env.citation_cff_version == steps.latest_version.outputs.latestVersion) || | |
(env.readme_rst_version == steps.latest_version.outputs.latestVersion) }} | |
run: | | |
echo "Version numbers in source have not been updated." | |
exit 1 |