Skip to content

Commit

Permalink
chore: [IA-209] Update publiccode.yml when a new version of the app i…
Browse files Browse the repository at this point in the history
…s released (#3335)

* test

* fix

* update date

* update publiccode.yml

* fix

* update comments

* remove unused import

* remove variable
  • Loading branch information
fabriziofff authored Aug 30, 2021
1 parent 25f7bfa commit a5fe299
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .versionrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
{
"filename": "android/app/build.gradle",
"updater": "scripts/changelog/gradle_updater.js"
},
{
"filename": "publiccode.yml",
"updater": "scripts/changelog/publiccode_updater.js"
}
]

Expand Down
10 changes: 5 additions & 5 deletions publiccode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

publiccodeYmlVersion: '0.2'
name: IO
releaseDate: '2019-05-02'
releaseDate: '2021-08-27'
url: 'https://github.com/pagopa/io-app'
applicationSuite: IO
landingURL: 'https://io.italia.it/'
softwareVersion: 0.1.0
softwareVersion: 1.33.0-rc.9
developmentStatus: beta
softwareType: standalone/mobile
roadmap: 'https://io.italia.it/'
Expand All @@ -20,11 +20,11 @@ categories:
maintenance:
type: internal
contacts:
- name: Federico Feroldi
email: federico.feroldi@pagopa.it
- name: Matteo Boschi
email: matteo.boschi@pagopa.it
legal:
license: EUPL-1.2
mainCopyrightOwner: pagoPA SpA
mainCopyrightOwner: PagoPA S.p.A.
repoOwner: https://www.pagopa.it/
authorsFile: AUTHORS.md
intendedAudience:
Expand Down
43 changes: 43 additions & 0 deletions scripts/changelog/publiccode_updater.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* This is an updater for the utility "standard-version" that increase the versionName value
* for publiccode.yml file.
* Replace the line:
* softwareVersion: $VERSION
* with the new generated version.
*
* and the line:
* releaseDate: '$DATE'
* with the today date.
*
*/

const softwareVersionRegex = /(softwareVersion: )(.+)/gm;
const releaseDateRegex = /(releaseDate: ')(.+)(')/gm;

module.exports.readVersion = function (contents) {
// return the 2nd group of the regex (the version)
return softwareVersionRegex.exec(contents)[2];
};

function replaceReleaseDate(_, version, p1, p2, p3) {
return [p1, version, p3].join("");
}

function replaceVersionName(_, version, p1) {
return [p1, version].join("");
}

module.exports.writeVersion = function (contents, version) {
// Update version
contents = contents.replace(softwareVersionRegex, (substr, ...args) =>
replaceVersionName(substr, version, ...args)
);
const today = new Date().toISOString().split("T")[0];

// update date
contents = contents.replace(releaseDateRegex, (substr, ...args) =>
replaceReleaseDate(substr, today, ...args)
);

return contents;
};

0 comments on commit a5fe299

Please sign in to comment.