Skip to content

Merge Release 3.3.4 into stable #44

Merge Release 3.3.4 into stable

Merge Release 3.3.4 into stable #44

# Check package.json to see if the version number is different.
# If it isn't changed, then yell at the user.
name: "CheckPackageVersionChanged"
on:
push:
branches: [ "stable" ]
pull_request:
branches: [ "stable" ]
workflow_call:
inputs:
new-branch:
description: 'Branch that contains changes. If the context does not have a branch, use this. If context is not provided, this is required.'
required: false
default: ''
type: string
old-branch:
description: 'Branch to compare against. Defaults to main, should be whatever branch is the primary branch.'
required: false
default: 'stable'
type: string
package-location:
description: 'File path to the package.json file to check. Includes the name of the file.'
required: false
default: 'com.playeveryware.eos/package.json'
type: string
env:
NEW_BRANCH_NAME: ${{ github.head_ref || github.ref_name || inputs.new-branch || 'stable' }}
OLD_BRANCH_NAME: ${{ inputs.old-branch || 'stable' }}
PACKAGE_LOCATION: ${{ inputs.package-location }}
jobs:
check_package_version_changed:
runs-on: ubuntu-latest
steps:
- name: Get New Package.json
id: get_new_package_json
uses: actions/github-script@v7
with:
script: |
const response = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: 'com.playeveryware.eos/package.json',
ref: '${{ env.NEW_BRANCH_NAME }}'
});
return Buffer.from(response.data.content, response.data.encoding).toString('utf-8');
result-encoding: string
- name: Get Old Package.json
id: get_old_package_json
uses: actions/github-script@v7
with:
script: |
const response = await github.rest.repos.getContent({
owner: context.repo.owner,
repo: context.repo.repo,
path: 'com.playeveryware.eos/package.json',
ref: '${{ env.OLD_BRANCH_NAME }}'
});
return Buffer.from(response.data.content, response.data.encoding).toString('utf-8');
result-encoding: string
- name: Extract Value of New Package.json
run: |
echo "new_package_value=${{ fromJson(steps.get_new_package_json.outputs.result).version }}" >> $Env:GITHUB_ENV
shell:
pwsh
- name: Extract Value of Old Package.json
run: |
echo "old_package_value=${{ fromJson(steps.get_old_package_json.outputs.result).version }}" >> $Env:GITHUB_ENV
shell:
pwsh
- name: Compare package.json values
if: ${{ Env.old_package_value == Env.new_package_value }}
run: |
echo "::error file=toplevelfile.json::The package.json version was not changed between commits. Failing job."
exit 1