Skip to content

Commit

Permalink
🛠 Set version code explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
MarmadileManteater committed Jan 15, 2023
1 parent a8944f6 commit abb4f0a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/buildCordova.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:
- name: Set Version Number Variable
id: versionNumber
uses: actions/github-script@v6
env:
VERSION_NUMBER_DEVELOPMENT: ${{ env.PACKAGE_VERSION }}.${{ github.run_number }}
with:
result-encoding: string
script: |
const [ packageVersion, runNumber ] = ["${{ env.PACKAGE_VERSION }}", "${{ github.run_number }}"]
const [ major, minor, patch ] = packageVersion.split(".")
return `${major * 10000000 + minor * 100000 + patch * 1000 + runNumber}`
return "${{ env.VERSION_NUMBER_DEVELOPMENT }}"
- name: Update package.json version
uses: jossef/action-set-json-field@v2
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/releaseCordova.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,22 @@ jobs:
- name: Set Version Number Variable
id: versionNumber
uses: actions/github-script@v6
env:
IS_DEV: ${{ contains(github.ref, 'development') }}
IS_NIGHTLY: ${{ contains(github.ref, 'release') }}
VERSION_NUMBER_DEVELOPMENT: ${{ env.PACKAGE_VERSION }}-development-${{ github.run_number }}
VERSION_NUMBER_NIGHTLY: ${{ env.PACKAGE_VERSION }}-nightly-${{ github.run_number }}
VERSION_NUMBER_RELEASE: ${{ env.PACKAGE_VERSION }}-unofficial
with:
result-encoding: string
script: |
const [ packageVersion, runNumber ] = ["${{ env.PACKAGE_VERSION }}", "${{ github.run_number }}"]
const [ major, minor, patch ] = packageVersion.split(".")
return `${major * 10000000 + minor * 100000 + patch * 1000 + runNumber}`
if (${{ env.IS_DEV }}) {
return "${{ env.VERSION_NUMBER_DEVELOPMENT }}"
} else if (${{ env.IS_NIGHTLY }}) {
return "${{ env.VERSION_NUMBER_NIGHTLY }}"
} else {
return "${{env.VERSION_NUMBER_RELEASE }}"
}
# script: if ${{ env.IS_DEV }} then echo ":token :set-output name=VERSION_NUMBER::${{ env.VERSION_NUMBER_NIGHTLY }}" else echo "::set-output name=VERSION_NUMBER::${{ env.VERSION_NUMBER }}" fi

- name: Update package.json version
Expand All @@ -51,6 +61,7 @@ jobs:
field: version
value: ${{ steps.versionNumber.outputs.result }}


- name: Install libarchive-tools
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.runtime, 'linux-x64')
run: sudo apt -y install libarchive-tools; echo "Version Number ${{ toJson(job) }} ${{ toJson(needs) }}"
Expand Down
2 changes: 2 additions & 0 deletions _scripts/cordova-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ const archiver = require('archiver');
const configXML = await parseXMLString(await fsReadFile(path.join(distDirectory, 'config.xml')))
configXML.widget.$.id = 'io.freetubeapp.' + sourcePackage.name
configXML.widget.$.version = sourcePackage.version
const [major, minor, patch, build] = sourcePackage.version.split('.')
configXML.widget.$['android-versionCode'] = `${major * 10000000 + minor * 100000 + patch * 1000 + build}`
configXML.widget.author[0].$.email = sourcePackage.author.email
configXML.widget.author[0]._ = sourcePackage.author.name
configXML.widget.author[0].$.href = sourcePackage.author.url
Expand Down

0 comments on commit abb4f0a

Please sign in to comment.