Integration #4
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: Version Checker | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
version-checker-main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install Dependencies | |
run: | | |
pip install --upgrade pip | |
pip install packaging poetry | |
- name: Checkout main Branch | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: main | |
- name: Get Version from main | |
run: | | |
COMPARED_VERSION="$(poetry version --short)" | |
echo COMPARED_VERSION="${COMPARED_VERSION}" >> ${GITHUB_ENV} | |
- name: Checkout Current Ref | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.ref }} | |
- name: Get Current Version | |
run: | | |
CURRENT_VERSION="$(poetry version --short)" | |
echo CURRENT_VERSION="${CURRENT_VERSION}" >> ${GITHUB_ENV} | |
if [ "${CURRENT_VERSION}" == "${COMPARED_VERSION}" ]; then | |
echo MATCH="true" >> ${GITHUB_ENV} | |
else | |
echo MATCH="false" >> ${GITHUB_ENV} | |
fi | |
- uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ env.MATCH == 'false' }} | |
with: | |
header: different-version-main | |
message: | | |
# Incorrect Version - pyproject.toml | |
Your version doesn't align with what's on the `main` branch. | |
Set your version to `${{ env.COMPARED_VERSION }}` to proceed: | |
```shell | |
poetry version ${{ env.COMPARED_VERSION }} | |
git add pyproject.toml | |
git commit -m "Version Bump - ${{ env.COMPARED_VERSION }}" | |
git push | |
``` | |
- uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ env.MATCH == 'true' }} | |
with: | |
header: different-version-main | |
delete: true | |
- name: Raise Error | |
if: ${{ env.MATCH == 'false' }} | |
run: | | |
echo "Versions don't align: ${CURRENT_VERSION} ${COMPARED_VERSION}" | |
echo "This repository updates the version automatically using labels" | |
exit 1 |