Skip to content

Commit

Permalink
Add release github action to auto bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
JeltevanBoheemen committed Jun 18, 2024
1 parent 8f08d1a commit ab174a4
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This action will update the CITATION.cff file for new release or hotfix branches

name: Release

on:
push:
branches:
- 'release/**'
- 'hotfix/**'

jobs:
citation-update:
name: Update CITATION.cff
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Autoformat CITATION.cff
run: |
version=`grep -o '\d\+\.\d\+\.\d\+' package.json`
today=`date +"%Y-%m-%d"`
sed -i "s/^version: [[:digit:]]\{1,\}\.[[:digit:]]\{1,\}\.[[:digit:]]\{1,\}/version: $version/" CITATION.cff
sed -i "s/[[:digit:]]\{4\}-[[:digit:]]\{2\}-[[:digit:]]\{2\}/$today/" CITATION.cff
bash ./update-citation.sh
git commit -a -m "update version and date in CITATION.cff"
4 changes: 4 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ Thumbs.db

# Angular
.angular/


/src/environments/environment.prod.ts
/src/environments/version.ts
39 changes: 39 additions & 0 deletions frontend/build/build-pre.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const path = require('path');
const colors = require('colors/safe');
const fs = require('fs');

console.log(colors.cyan('\nRunning pre-build tasks'));

var appVersion;

try {
appVersion = require('../../package.json').version;
} catch {
console.warn('Could not import package.json.');
appVersion = undefined;
}

const versionFilePath = path.join(
__dirname + '/../src/environments/version.ts'
);
const src = `export const version = '${appVersion}';
`;

// ensure version module pulls value from package.json
fs.writeFile(versionFilePath, src, { flat: 'w' }, function (err) {
if (err) {
return console.log(colors.red(err));
}

console.log(
colors.green(
`Updating application version ${colors.yellow(appVersion)}`
)
);
console.log(
`${colors.green('Writing version module to ')}${colors.yellow(
versionFilePath
)}\n`
);
console.log(src);
});
3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"build": "ng build --base-href=/static/",
"test": "ng test --watch=true",
"lint": "ng lint",
"prebuild": "node ./build/build-pre.js",
"pretest": "yarn prebuild",
"preserve": "yarn prebuild",
"build:en": "ng build --configuration=production-en",
"build:nl": "ng build --configuration=production-nl",
"build-git": "ng build --configuration git --aot",
Expand Down

0 comments on commit ab174a4

Please sign in to comment.