Closed Glusk closed 4 years ago
@rultor hello
.rultor.yml
draft:
architect:
- Glusk2
docker:
image: mingc/android-build-box:1.12.0
release:
script:
- chmod +x gradlew
# Increment versionCode
- perl -i.orig -pe '/versionCode/ && s/(\d+)/$1+1 . $2/e' android/build.gradle
# Strip tag of the "v" prefix
- version=${tag#"v"}
# Bump project version
- ./gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=$version -Prelease.newVersion=$version-SNAPSHOT
bash script to increment versionCode
(adopted from https://stackoverflow.com/questions/38366410):
perl -i.orig -pe '/versionCode/ && s/(\d+)/$1+1 . $2/e' android/build.gradle
Gradle release plugin requires to have the version stored in gradle.properties
Keeps failing with:
Execution failed for task ':sprouts:checkCommitNeeded'.
> You have uncommitted files:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
M gradle.properties
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It doesn't work! Still reports uncommited when trying to run the release
plugin.
I'm giving up on gradle-release
plugin!
Manually pick out gradle-release
steps
echo "$tag" | ./gradlew updateVersion
git commit -am "$tag"
# create a new tag for the latest commit
echo "$tag-SNAPSHOT" | ./gradlew updateVersion
git commit -am "$tag-SNAPSHOT" Can't do this with rultor. Rultor tags the **last** commit.
Rultor only pushes the release tag. Because it doesn't push to master
, the version doesn't get updated.
Sample action yml:
on:
issue_comment:
types: [created]
jobs:
release:
runs-on: ubuntu-latest
if: contains(${{ github.event.comment.body }}, 'Github, please release version:')
env:
COMMENT_BODY: ${{ github.event.comment.body }}
MSG_REGEX: "Github, please release version: v[0-9]+.[0-9]+.[0-9]+"
TAG_REGEX: "v[0-9]+.[0-9]+.[0-9]+"
steps:
- name: Checkout master branch
uses: actions/checkout@master
- name: Install Java
uses: actions/setup-java@v1
with:
java-version: 12
- name: Install Android SDK
uses: malinskiy/action-android/install-sdk@release/0.0.2
- name: Install Android packages
run: ./$ANDROID_HOME/tools/bin/sdkmanager "platforms;android-28" "platform-tools" "build-tools;28.0.3"
- name: Initialize Git user
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Test new release
run: |
# Get the tag from ${{ github.event.comment.body }}
tag=$(echo $COMMENT_BODY | grep -E "$MSG_REGEX" | grep -Eo "$TAG_REGEX")
if [[ $tag == "" ]]; then return -1; fi
# Strip the 'v' prefix from the tag for version
version=${tag#"v"}
# Bump versions
perl -i.orig -pe '/versionCode/ && s/([0-9]+)/$1+1 . $2/e' android/build.gradle
chmod +x gradlew
./gradlew updateVersion -Prelease.useAutomaticVersion=true -Prelease.newVersion=$version
# Build the project
./gradlew build connectedCheck
if [[ $? ]]
then
# Tag the new version
git commit -am "Bumped project version to $tag"
git tag -a $tag -m "Release $tag"
# Bump to snapshot
./gradlew updateVersion -Prelease.useAutomaticVersion=true -Prelease.newVersion=$version-SNAPSHOT
git commit -am "Bumped project version to $tag-SNAPSHOT"
else
return -1
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Github, please release version: v0.9.2
Github, please release version: v0.9.2
Github, please release version: v0.9.2
Github, please release version: v0.9.2
Github, please release version: v0.9.2
Github, please release version: v0.9.2
The release action should post a reply to the issue with some status info during the release.
Github, please release version: v0.10.1
Github, please release version: throwaway
Resources:
https://stackoverflow.com/questions/21405457(We don't want to incrementversionCode
on every build)