chkfung / android-version-actions Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
How do you get the current versionName and versionCode?
My use case is to append some text into the versionName.
For example, current versionName is "1.2.3", then I want it to be "1.2.3-hotfix"
My current internal release is 3 (1.0.3), so I would expect Version Code : 6 to replace the current release.
Testing:
Increasing versionCode in gradle to match the number from the GitHub run - this produces the same error.
Run chkfung/[email protected]
with:
gradlePath: app/build.gradle
versionCode: 6
versionName: 1.0.4
env:
JAVA_HOME_11.0.11_x64: /opt/hostedtoolcache/jdk/11.0.11/x64
JAVA_HOME: /opt/hostedtoolcache/jdk/11.0.11/x64
JAVA_HOME_11_0_11_X64: /opt/hostedtoolcache/jdk/11.0.11/x64
Gradle Path : app/build.gradle
Version Code : 6
Version Name : 1.0.4
/home/runner/work/_actions/chkfung/android-version-actions/v1.1/index.js:21
newGradle = newGradle.replace(versionCodeRegexPattern, $1$***versionCode***
);
^
TypeError: Cannot read property 'replace' of undefined
at ReadFileContext.callback (/home/runner/work/_actions/chkfung/android-version-actions/v1.1/index.js:21:35)
at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:239:13)
Warning: The set-output
command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information, see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
I was scratching my head why this action wasn't working for me. After some debugging I realized that it had managed to replace versionCode
in a comment (e.g. // Here's a sentence with versionCode in it
). The replacement mechanism needs to be a bit more robust. At the very least a regex that doesn't match on a comment line.
Hello,
I want to show the current build version code on the login screen of my application. I am showing the BuildConfig.VERSION_CODE to get the value, but it is still set to default value and is not overridden during build of the apk on Github:
Row {
Text(text = "App version: ${BuildConfig.VERSION_CODE}")
}
I am using this to increment the version code in github action workflow, which works fine and the version code is incremented:
- name: Set version code and version name
uses: chkfung/[email protected]
with:
gradlePath: app/build.gradle.kts
versionCode: ${{github.run_number}}
versionName: app_1.0.0_${{github.run_number}}
Thank you.
GitHub gives warning for the current version of the action (v1.1)
Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: chkfung/android-version-actions
Hey @chkfung, thanks for the plugin.
Is it feasible for you to put replaceAll in place of newGradle = newGradle.replace(versionCodeRegexPattern,
);
and same for versionName because we have multiple productFlavours with each flavour having its own versionCode and versionName, but it only replaces just the first occurrence.
Originally posted by @alisultan-cloaked in #2 (comment)
The following actions uses node12 which is deprecated and will be forced to run on node16: chkfung/android-version-actions@v1. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
Using following code:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Bump version
uses: chkfung/[email protected]
with:
gradlePath: app/build.gradle
versionCode: ${{github.run_number}}
versionName: 1.0.8
Failing with following error message:
**Run chkfung/[email protected]
Gradle Path : app/build.gradle
Version Code : 17
Version Name : 1.0.8
/home/runner/work/_actions/chkfung/android-version-actions/v1.1/index.js:21
newGradle = newGradle.replace(versionCodeRegexPattern, $1$***versionCode***
);
^
TypeError: Cannot read property 'replace' of undefined
at ReadFileContext.callback (/home/runner/work/_actions/chkfung/android-version-actions/v1.1/index.js:21:35)
at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:261:13)**
Hi! I would like to use this plug-in to update our versionCode
and versionName
using GitHub Actions, but I do not seem to be getting any results. I am new to using GitHub actions, and so I could be doing something wrong. The file I created is .github/workflows/android-version-action.yml
and looks like this:
name: Bump the version code
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Bump version
uses: chkfung/[email protected]
with:
gradlePath: app/build.gradle # or app/build.gradle.kts
versionCode: ${{github.run_number}}
versionName: 1.0.0
This is the output of the "Bump version" step in the workflow:
Run chkfung/[email protected]
with:
gradlePath: app/build.gradle
versionCode: 4
versionName: 1.0.0
env:
JAVA_HOME_8.0.302_x64: /opt/hostedtoolcache/jdk/8.0.302/x64
JAVA_HOME: /opt/hostedtoolcache/jdk/8.0.302/x64
JAVA_HOME_8_0_302_X64: /opt/hostedtoolcache/jdk/8.0.302/x64
Gradle Path : app/build.gradle
Version Code : 4
Version Name : 1.0.0
Successfully override version code 4
Successfully override version code 1.0.0
I would expect the build.gradle
file to contain versionCode
4 and versionName
1.0.0 but nothing seems to have happened. Thanks for making this plug-in and I appreciate any help or support!
Thanks for this great action!
My problem is that the job that includes this action has the following properties set for the job (it's a monorepo with servers, web apps and several Android apps):
defaults:
run:
working-directory: ./Apps/Android/Root
When I try to use the action:
- name: + Bump Android App #1 version
uses: chkfung/[email protected]
with:
gradlePath: app-one/build.gradle
versionCode: ${{ env.ANDROID_BUILD_CODE }}
the action fails, but if I change it to:
- name: + Bump Android App #1 version
uses: chkfung/[email protected]
with:
gradlePath: Apps/Android/Root/app-one/build.gradle
versionCode: ${{ env.ANDROID_BUILD_CODE }}
then the action works correctly.
PROBLEM: The action should respect the job's working-directory
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.