PLUG-155: Verify version and autorelease in pipelines #21
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 config.xml version | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
branches: [main] | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 0 | |
- name: Set OLD_VERSION from etc/config.xml if merge would modify it | |
run: | | |
echo "OLD_VERSION=$(git log origin/main..HEAD --cherry -p -- etc/config.xml | grep '\-.\s*.<version>' | tail -1 | tr -d '\-[:blank:]\n' | sed -e 's/<version>\(.*\)<\/version>/\1/')" >> $GITHUB_ENV | |
- name: Set NEW_VERSION from etc/config.xml if merge would modify it | |
run: | | |
echo "NEW_VERSION=$(git log origin/main..HEAD --cherry -p -- etc/config.xml | grep '\+.\s*.<version>' | head -1 | tr -d '+[:blank:]\n' | sed -e 's/<version>\(.*\)<\/version>/\1/')" >> $GITHUB_ENV | |
- name: Print versions | |
run: | | |
echo "Old version: ${OLD_VERSION:-unknown}; New version: ${NEW_VERSION:-unknown}" | |
- name: Test that versions are not empty | |
run: | | |
[[ ! -z $OLD_VERSION ]] && [[ ! -z $NEW_VERSION ]] | |
- name: Test that versions are different | |
run: | | |
[[ $OLD_VERSION != $NEW_VERSION ]] | |
- name: Sort versions | |
run: | | |
echo "GREATER_VERSION=$(echo $OLD_VERSION\\\n$NEW_VERSION | sort --version-sort | tail -n1)" >> $GITHUB_ENV | |
- name: Make sure new version is greater | |
run: | | |
[[ $GREATER_VERSION == $NEW_VERSION ]] |