Skip to content

Commit

Permalink
add only version code bump
Browse files Browse the repository at this point in the history
  • Loading branch information
timo-a committed Jun 10, 2021
1 parent bfe0a93 commit 0063e7a
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 43 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/version-bump-Commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ on:

# 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 }}"
increase-version:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -61,10 +54,10 @@ jobs:
git add -A
NEW_VERSION_CODE=${{ steps.increase_version_code.outputs.new_version_code }}
NEW_VERSION_NAME=${{ steps.increase_version_name.outputs.new_version_name }}
git commit -m "version bump: code: ${NEW_VERSION_CODE}, name: ${NEW_VERSION_NAME}" -a
git commit -m "Version bump: code: ${NEW_VERSION_CODE}, name: ${NEW_VERSION_NAME}" -a
# - name: push changes
# uses: ad-m/[email protected]
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# branch: ${{ github.ref }}
- name: push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
45 changes: 15 additions & 30 deletions .github/workflows/version-bump-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,13 @@ on:
default: 'p'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
#print inputs
printInputs:
increase-version:
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
id: increase_version_code
env:
FILE: sudoq-app/sudoqapp/src/main/AndroidManifest.xml
run: |
Expand All @@ -53,21 +28,31 @@ jobs:
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 "current version: ${VERSION}"
echo "replace version"
sed -i "${LINE_NUMBER}s/${VERSION}/$((VERSION+1))/" $FILE
NEW_VERSION_CODE=$((VERSION+1))
echo "new version code: ${NEW_VERSION_CODE}"
sed -i "${LINE_NUMBER}s/${VERSION}/${NEW_VERSION_CODE}/" $FILE
echo "::set-output name=new_version_code::$NEW_VERSION_CODE"

# sets NEW_VERSION_NAME
- name: increase version name
id: increase_version_name
env:
FILE: sudoq-app/sudoqapp/src/main/AndroidManifest.xml
SCRIPT: .github/workflows/incrementVersionName.py
run : |
python $SCRIPT $FILE ${{ github.event.inputs.changeSeverity }}
echo "$NEW_VERSION_NAME"
echo "::set-output name=new_version_name::$(cat new_version_name.txt)"

- name: commit files
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: increase version
commit-message: >-
Version bump: code: ${{ steps.increase_version_code.outputs.new_version_code }},
name: ${{ steps.increase_version_code.outputs.new_version_name }}
title: '[Experiment] increase version'
body: >
This PR is auto-generated by
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/version-code-bump-Commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This is a basic workflow to help you get started with Actions

name: 'bump versionCode, versionName, commit'

on:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
changeSeverity:
description: 'how severe are the changes? chose from (M)ajor, (m)inor, (p)atch, or write out the new version'
required: true
default: 'p'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
increase-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: increase version code
id: 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 "current version: ${VERSION}"
echo "replace version"
NEW_VERSION_CODE=$((VERSION+1))
echo "new version code: ${NEW_VERSION_CODE}"
sed -i "${LINE_NUMBER}s/${VERSION}/${NEW_VERSION_CODE}/" $FILE
echo "::set-output name=new_version_code::$NEW_VERSION_CODE"
- name: commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
NEW_VERSION_CODE=${{ steps.increase_version_code.outputs.new_version_code }}
git commit -m "Version code bump: code: ${NEW_VERSION_CODE}" -a
- name: push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}

0 comments on commit 0063e7a

Please sign in to comment.