Skip to content

Commit

Permalink
ops: check version changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gomeslucasm committed Apr 16, 2024
1 parent 82950e3 commit 11f48f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 48 deletions.
34 changes: 12 additions & 22 deletions .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,16 @@ jobs:
version-check:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'opened' || github.event.action == 'synchronize'
steps:
- name: Checkout code
uses: actions/checkout@v2
script:
- TARGET_BRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- TARGET_VERSION=$(git show origin/$TARGET_BRANCH:src/package.json | grep '"version"' | cut -d '"' -f 4)
- CURRENT_VERSION=$(cat src/package.json | grep '"version"' | cut -d '"' -f 4)
- echo "Versão na branch $TARGET_BRANCH: $TARGET_VERSION"
- echo "Versão na branch atual: $CURRENT_VERSION"
- if [ "$TARGET_VERSION" == "$CURRENT_VERSION" ]; then
echo "Erro: Version is equal, change version to publish changes on NPM!";
exit 1;
else
echo "Different versions, changes will be published";
fi

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18"

- name: Go to path
run: cd src

- name: Install dependencies
run: npm install

- name: Check if version changed
id: version-check
run: |
CHANGED=$(git show --name-only --oneline HEAD~1..HEAD package.json)
if [[ -z "$CHANGED" ]]; then
echo "No changes to package.json. Version must be updated before merging."
exit 1
fi
39 changes: 13 additions & 26 deletions .github/workflows/upgrade-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,19 @@ on:
- "src/**"

jobs:
version-check:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18"

- name: Go to path
run: cd src

- name: Install dependencies
run: npm install

- name: Check if version changed
id: version-check
run: |
CHANGED=$(git diff --name-only HEAD~1 package.json)
if [[ -z "$CHANGED" ]]; then
echo "No changes to package.json. Version must be updated before merging."
exit 1
fi
check-version:
script:
- TARGET_BRANCH=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
- TARGET_VERSION=$(git show origin/$TARGET_BRANCH:src/package.json | grep '"version"' | cut -d '"' -f 4)
- CURRENT_VERSION=$(cat src/package.json | grep '"version"' | cut -d '"' -f 4)
- echo "Versão na branch $TARGET_BRANCH: $TARGET_VERSION"
- echo "Versão na branch atual: $CURRENT_VERSION"
- if [ "$TARGET_VERSION" == "$CURRENT_VERSION" ]; then
echo "Erro: Version is equal, change version to publish changes on NPM!";
exit 1;
else
echo "Different versions, changes will be published";
fi

publish:
runs-on: ubuntu-latest
Expand Down

0 comments on commit 11f48f1

Please sign in to comment.