Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experiment] increase version #3

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
33 changes: 33 additions & 0 deletions .github/workflows/incrementVersionName.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fileinput
import sys

#input validation
#must be (b|n|p) for breaking, non breaking, patch
#any word starting with b/n/p works
if not sys.argv[2]:
print("Error: no position argument given", file = sys.stderr )

print("file is: " + sys.argv[1])
print("position argument is: " + sys.argv[2])

position = sys.argv[2][0]


if position not in "bnp":
print("Error: position argument is not valid", file = sys.stderr )

for line in fileinput.input(files=(sys.argv[1]), inplace=True):
if line.find("android:versionName=") >= 0:
versionName = line.split('"')[1]

(b,n,p) = versionName.split('.')
if position == 'b':
b = str(int(b) + 1)
elif position == 'n':
n = str(int(n) + 1)
else:
p = str(int(p) + 1)

versionNameIncremented = '.'.join((b,n,p))
line = line.replace(versionName, versionNameIncremented)
print(line, end='')
80 changes: 80 additions & 0 deletions .github/workflows/version-experiments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run.
on:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
changeSeverity:
description: 'how severe are the changes? chose from b,n,p'
required: true
default: 'p'
tags:
description: 'Test scenario tags'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
#print inputs
printInputs:
runs-on: ubuntu-latest
steps:
- run: |
echo "Log level: ${{ github.event.inputs.changeSeverity }}"
echo "Tags: ${{ github.event.inputs.tags }}"

build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
experiments:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: increase version code
env:
FILE: sudoq-app/sudoqapp/src/main/AndroidManifest.xml
run: |
echo "$(pwd)"
echo "get line number"
LINE_NUMBER=$(grep -n "android:versionCode=" $FILE | cut -f1 -d:)
echo "get version"
VERSION=$(sed -n ${LINE_NUMBER}p $FILE | grep -oE '[0-9]+')
echo "replace version"
sed -i "${LINE_NUMBER}s/${VERSION}/$((VERSION+1))/" $FILE

- name: increase version number
run : |
FILE=sudoq-app/sudoqapp/src/main/AndroidManifest.xml
echo "$(ls)"
python .github/workflows/incrementVersionName.py $FILE ${{ github.event.inputs.changeSeverity }}
echo "Log level: ${{ github.event.inputs.changeSeverity }}"
echo "Tags: ${{ github.event.inputs.tags }}"

- name: commit files
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: increase version
title: '[Experiment] increase version'
body: >
This PR is auto-generated by
[create-pull-request](https://github.com/peter-evans/create-pull-request).
labels: report, automated pr

4 changes: 2 additions & 2 deletions sudoq-app/sudoqapp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<!-- This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.sudoq"
android:versionCode="27"
android:versionName="1.1.1"
android:versionCode="28"
android:versionName="1.1.2"
android:installLocation="auto" >

<application
Expand Down