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

add git action to bump version number #61

Merged
merged 5 commits into from
Jan 9, 2025
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
77 changes: 77 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Version Bump

on:
pull_request:
types: [opened, reopened]

jobs:
version-bump:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: npm install

- name: Set up GPG keys for signing
run: |
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
git config --global user.signingkey ${{ secrets.GPG_KEY_ID }}
git config --global commit.gpgsign true
git config --global user.email ${{ secrets.GPG_EMAIL }}
git config --global user.name ${{ secrets.GPG_NAME }}
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
GPG_EMAIL: ${{ secrets.GPG_EMAIL }}
GPG_NAME: ${{ secrets.GPG_NAME }}

- name: Commit dependency updates with GPG sign
run: |
git add package-lock.json
git commit -S -m "update package-lock.json" || echo "No changes to commit"

- name: Fetch main branch
run: git fetch origin main

- name: Merge main into feature branch
run: |
git merge origin/main --no-commit
continue-on-error: true

- name: Check for merge conflicts
run: |
if [[ $(git ls-files -u | wc -l) -gt 0 ]]; then
echo "Merge conflicts detected. Exiting without version bump."
exit 0
else
echo "Merge successful. Proceeding with version bump."
fi
shell: bash

- name: Commit merged changes
run: |
git commit -S -m "merge main into feature branch" || echo "No changes to commit"

- name: Bump version number
run: |
npm version patch

- name: Ensure branch is checked out
run: |
git checkout ${{ github.head_ref }}

- name: Push version bump and commit with GPG sign
run: |
git push --set-upstream origin ${{ github.head_ref }} --force
git push --tags
10 changes: 5 additions & 5 deletions .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
version: v1.25.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore:
SNYK-JS-AXIOS-7361793:
- '*':
reason: no direct upgrade
expires: 2024-08-24T09:33:30.658Z
created: 2024-08-13T08:31:30.658Z
SNYK-JS-AXIOS-6671926:
- "*":
reason: no direct upgrade
expires: 2025-01-23T15:22:30.658Z
created: 2025-01-09T15:22:30.658Z
patch: {}
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-doc-statement-generator",
"version": "2.5.33",
"version": "2.5.34",
"description": "FFC payment statement generator",
"homepage": "https://github.com/DEFRA/ffc-doc-statement-generator",
"main": "app/index.js",
Expand Down Expand Up @@ -63,4 +63,4 @@
"**/test-output/**"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jest.mock('moment', () => {

describe('getPeriodStartDateFromPeriod', () => {
test('should correctly parse the start date from a period string', () => {
const period = '1 January to 31 December 2024'
const expectedStartDate = new Date('2024-01-01T00:00:00.000Z')
const period = '1 January to 31 December 2025'
const expectedStartDate = new Date('2025-01-01T00:00:00.000Z')

const startDate = getPeriodStartDateFromPeriod(period)

Expand Down