44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
name: Verify package.json version
|
|
description: This action will provide $PACKAGE_VERSION env variable, and
|
|
|
|
inputs:
|
|
package_json_path:
|
|
description: Path to package.json file
|
|
default: package.json
|
|
outputs:
|
|
version_changed:
|
|
description: "Whether the version changed"
|
|
value: ${{ steps.check.outputs.version_changed }}
|
|
package_version:
|
|
description: "Current version from package.json"
|
|
value: ${{ steps.check.outputs.package_version }}
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Instalando Dependencias
|
|
shell: sh
|
|
run: apk add git jq
|
|
|
|
- name: Checkout do repositório
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2 # Necessário para acessar o commit anterior
|
|
|
|
- name: Verificar mudança de versão no package.json
|
|
id: check-package-version
|
|
shell: sh
|
|
run: |
|
|
OLD_VERSION=$(git show HEAD^:${{ inputs.package_json_path }} | jq -r '.version')
|
|
NEW_VERSION=$(jq -r '.version' ${{ inputs.package_json_path }})
|
|
|
|
echo "Versão anterior: $OLD_VERSION"
|
|
echo "Versão atual: $NEW_VERSION"
|
|
|
|
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
|
|
echo "version_changed=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "version_changed=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
echo "package_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|