Skip to content

Commit

Permalink
Reverse versioning override
Browse files Browse the repository at this point in the history
  • Loading branch information
kschrief committed Mar 25, 2024
1 parent 3b81a54 commit 40c70b6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 52 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,10 @@ jobs:
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}"
# Get the "next" version number
- name: Extract next version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "main"
- name: Checkout main
run: git checkout "main"

# Update "main" version to match "next"
- name: Update "main" version to match "next"
run: |
jq '.version = "${{ steps.extract_version.outputs.version }}"' package.json > temp.json
if diff -q "package.json" "temp.json" >/dev/null; then
echo "Versions are identical. No change required."
rm temp.json
else
mv temp.json package.json
git add package.json && git commit -m "Sync version to ${{ steps.extract_version.outputs.version }}"
fi
# Attempt a dry-run merge
- name: Attempt a dry-run merge
run: |
Expand Down Expand Up @@ -70,28 +52,10 @@ jobs:
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}"
# Get the "next" version number
- name: Extract next version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "main"
- name: Checkout main
run: git checkout "main"

# Update "main" version to match "next"
- name: Update "main" version to match "next"
run: |
jq '.version = "${{ steps.extract_version.outputs.version }}"' package.json > temp.json
if diff -q "package.json" "temp.json" >/dev/null; then
echo "Versions are identical. No change required."
rm temp.json
else
mv temp.json package.json
git add package.json && git commit -m "Sync version to ${{ steps.extract_version.outputs.version }}"
fi
- name: Perform the merge from next to main
run: |
git merge origin/next
Expand Down
44 changes: 28 additions & 16 deletions .github/workflows/merge-to-next-major.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ jobs:
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}"
# Get the "next" version number
- name: Extract next version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

# Update "next-major" version to match "next"
- name: Update "next-major" version to match "next"
# Get the "next-major" version number
- name: Extract next-major version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "next"
- name: Checkout next
run: git checkout "next"

# Update "next" version to match "next-major"
- name: Update "next" version to match "next-major"
run: |
jq '.version = "${{ steps.extract_version.outputs.version }}"' package.json > temp.json
Expand All @@ -46,10 +50,14 @@ jobs:
git add package.json && git commit -m "Sync version to ${{ steps.extract_version.outputs.version }}"
fi
# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

# Attempt a dry-run merge
- name: Attempt a dry-run merge
run: |
git merge --no-commit --no-ff origin/${{github.ref_name}}
git merge --no-commit --no-ff ${{github.ref_name}}
exit $?
# Attempt to merge to next-major if our dry-run succeeded
Expand All @@ -73,17 +81,21 @@ jobs:
git config --global user.email "${{ secrets.GLOBAL_GITHUB_EMAIL }}"
git config --global user.name "${{ secrets.GLOBAL_GITHUB_USER }}"
# Get the "next" version number
- name: Extract next version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "next-major"
- name: Checkout next-major
run: git checkout "next-major"

# Update "next-major" version to match "next"
- name: Update "next-major" version to match "next"
# Get the "next-major" version number
- name: Extract next-major version
id: extract_version
run: echo "::set-output name=version::$(node -e 'console.log(require("./package.json").version)')"

# Checkout "next"
- name: Checkout next
run: git checkout "next"

# Update "next" version to match "next-major"
- name: Update "next" version to match "next-major"
run: |
jq '.version = "${{ steps.extract_version.outputs.version }}"' package.json > temp.json
Expand All @@ -97,7 +109,7 @@ jobs:
- name: Perform the merge from next to next-major
run: |
git merge origin/next
git merge next
merge_status=$?
git push origin "next-major"
Expand Down

0 comments on commit 40c70b6

Please sign in to comment.