Skip to content

PSG-4788 bump version + changelog #67

PSG-4788 bump version + changelog

PSG-4788 bump version + changelog #67

Workflow file for this run

name: PR Checks
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- 'lib/passageidentity/version.rb'
- 'CHANGELOG.md'
env:
API_KEY: ${{ secrets.API_KEY }}
APP_ID: ${{ secrets.APP_ID }}
PSG_JWT: ${{ secrets.PSG_JWT }}
TEST_USER_ID: ${{ secrets.TEST_USER_ID }}
jobs:
build:
name: Test and Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
- name: Run Tests
run: |
bundle install
ruby tests/all.rb
- name: Run Linting
run: |
npm install -g prettier @prettier/plugin-ruby
prettier --check '**/*.rb'
check-version-bump:
name: Check Version and Changelog have been updated
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
- name: Fetch base branch
run: git fetch origin main
- name: Check for changes in version.rb and CHANGELOG.md
id: check_diff
run: |
if ! git diff --name-only origin/main...HEAD | grep -qE 'lib/passageidentity/version.rb|CHANGELOG.md'; then
echo "No changes detected in version.rb or CHANGELOG.md"
exit 1
fi
- name: Extract version from version.rb in current branch
id: extract_current_version
run: |
current_version=$(grep -Eo 'VERSION\s*=\s*["\'][0-9]+\.[0-9]+\.[0-9]+["\']' lib/passageidentity/version.rb | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
echo "::set-output name=current_version::$current_version"
- name: Extract latest version from CHANGELOG.md in current branch
id: extract_current_changelog_version
run: |
current_changelog_version=$(grep -Eo '\[([0-9]+\.[0-9]+\.[0-9]+)\]' CHANGELOG.md | head -n 1 | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
echo "::set-output name=current_changelog_version::$current_changelog_version"
- name: Extract version from version.rb in main branch
id: extract_main_version
run: |
main_version=$(git show origin/main:lib/passageidentity/version.rb | grep -Eo 'VERSION\s*=\s*["\'][0-9]+\.[0-9]+\.[0-9]+["\']' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
echo "::set-output name=main_version::$main_version"
- name: Compare versions
run: |
if [ "${{ steps.extract_current_version.outputs.current_version }}" == "${{ steps.extract_current_changelog_version.outputs.current_changelog_version }}" ] && [ "${{ steps.extract_current_version.outputs.current_version }}" != "${{ steps.extract_main_version.outputs.main_version }}" ]; then
echo "Versions match and have been updated: ${{ steps.extract_current_version.outputs.current_version }}"
else
echo "Version mismatch or no update detected: version.rb (${{ steps.extract_current_version.outputs.current_version }}), CHANGELOG.md (${{ steps.extract_current_changelog_version.outputs.current_changelog_version }}), main branch version.rb (${{ steps.extract_main_version.outputs.main_version }})"
exit 1
fi