Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bump version ci #248

Merged
merged 29 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .github/workflows/build-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,7 @@ on:
- main

jobs:
upgrade-project-version:
if: ${{ !contains(github.event.head_commit.message, '[RELEASE]') }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: apps/web/
steps:
-
name: checkout
uses: actions/checkout@v3
-
name: setup node
uses: actions/setup-node@v4
with:
node-version: 20
-
name: Upgrade project version
id: upgrade-version-step
run: |
npm version patch &&
NEW_VERSION=$(cat package.json | jq -r '.version')
echo "Version clean is $NEW_VERSION"
echo API_VERSION=$NEW_VERSION >> $GITHUB_OUTPUT
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git add .
git commit -m "[RELEASE] $NEW_VERSION"
git push
outputs:
API_VERSION: ${{ steps.upgrade-version-step.outputs.API_VERSION }}

docker-build:
needs: [upgrade-project-version]
runs-on: ubuntu-latest

steps:
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/bump-version-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Verify and Bump Version

on:
pull_request:
types: [opened, reopened]
branches:
- main # Trigger the action on PRs targeting the main branch

jobs:
verify-and-bump:
runs-on: ubuntu-latest

steps:
- name: Checkout the PR branch
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Get version from PR branch
id: pr-version
run: |
PR_VERSION=$(jq -r '.version' apps/web/package.json)
echo "::set-output name=pr_version::${PR_VERSION}"

- name: Checkout the main branch
uses: actions/checkout@v3
with:
ref: main

- name: Get version from main branch
id: main-version
run: |
MAIN_VERSION=$(jq -r '.version' apps/web/package.json)
echo "::set-output name=main_version::${MAIN_VERSION}"
- name: Compare versions
id: compare-versions
run: |
if [ "${{ steps.pr-version.outputs.pr_version }}" != "${{ steps.main-version.outputs.main_version }}" ]; then
echo "::set-output name=need_bump::'false'"
echo "The versions are different."
else
echo "::set-output name=need_bump::'true'"
echo "The versions are the same. Bump required."
fi
- name: Comment PR
if: contains(steps.compare-versions.outputs.need_bump, 'true')
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Please, update version of web project!
execute this command on terminal
```bash
cd apps/web && npm version patch
```
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web",
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"scripts": {
"dev": "development=true next dev",
Expand Down
Loading
Loading