action tag and version #86

Closed
opened 2025-08-04 20:50:47 +02:00 by lookshe · 2 comments
Owner

Create an action that does the following:

  • create a new tag based on the current defined versionName in piratx.gradle
  • update versionName and and versionCode
    • if possible ask the user to enter the next versionName
    • otherwise increment patch version
  • commit and push changes
Create an action that does the following: - create a new tag based on the current defined versionName in piratx.gradle - update versionName and and versionCode - if possible ask the user to enter the next versionName - otherwise increment patch version - commit and push changes
Author
Owner
on:
  workflow_dispatch:
    inputs:
      version_update:
        description: 'which part of semver should be updated?'
        required: true
        default: 'patch'
        type: choice
        options:
          - major
          - minor
          - patch

jobs:
  clean:
    if: forge.ref == 'refs/heads/master'
    runs-on: docker
    container:
      image: docker.io/alpine:3.22
    steps:
      - name: install needed packages
        run: apk update && apk add --no-cache openssh-client git bash
      - name: install ssh key
        run: |
          mkdir -p ~/.ssh
          echo "${{ secrets.SSH_PRIVATE_KEY_THEDEVSTACK_DE_PIRATX }}" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keyscan -p 2222 -H git.fucktheforce.de > ~/.ssh/known_hosts
      - name: clone original repo
        run: git clone ssh://git@git.fucktheforce.de:2222/lookshe/TestApplication.git workdir
      - name: gather info
        id: info
        run: |
          VERSION_NAME=$(grep 'versionName .*' app/build.gradle | sed -e 's/[^0-9\.]//g' | head -n1)
          echo "version_name=$VERSION_NAME" >> $FORGEJO_OUTPUT
          VERSION_CODE=$(grep 'versionCode .*' app/build.gradle | sed -e 's/[^0-9\.]//g' | head -n1)
          echo "version_code=$VERSION_CODE" >> $FORGEJO_OUTPUT
        working-directory: workdir
      - name: bump version
        id: bump
        uses: https://git.fucktheforce.de/actions/increment-semantic-version.git@1.2.3
        with:
          current-version: "${{ steps.info.outputs.version_name }}"
          version-fragment: "${{ inputs.version_update }}"
      - name: create tag and update version
        run: |
          git tag "v${{ steps.info.outputs.version_name }}"
          NEXT_VERSION_CODE=$(( ${{ steps.info.outputs.version_code }} + 1 ))
          sed -i -e 's/versionName .*/versionName "${{ steps.bump.outputs.next-version }}"/g' app/build.gradle
          sed -i -e "s/versionCode .*/versionCode $NEXT_VERSION_CODE/g" app/build.gradle
          git add app/build.gradle
          git commit -m "update version info after creating tag"
          git push
          git push --tags
        working-directory: workdir
        env:
          GIT_AUTHOR_NAME: "${{ vars.GIT_AUTHOR_NAME }}"
          GIT_AUTHOR_EMAIL: "${{ vars.GIT_AUTHOR_EMAIL }}"
          EMAIL: "${{ vars.GIT_AUTHOR_EMAIL }}"

gradle filename should be a variable and adjusted according to this project

``` on: workflow_dispatch: inputs: version_update: description: 'which part of semver should be updated?' required: true default: 'patch' type: choice options: - major - minor - patch jobs: clean: if: forge.ref == 'refs/heads/master' runs-on: docker container: image: docker.io/alpine:3.22 steps: - name: install needed packages run: apk update && apk add --no-cache openssh-client git bash - name: install ssh key run: | mkdir -p ~/.ssh echo "${{ secrets.SSH_PRIVATE_KEY_THEDEVSTACK_DE_PIRATX }}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa ssh-keyscan -p 2222 -H git.fucktheforce.de > ~/.ssh/known_hosts - name: clone original repo run: git clone ssh://git@git.fucktheforce.de:2222/lookshe/TestApplication.git workdir - name: gather info id: info run: | VERSION_NAME=$(grep 'versionName .*' app/build.gradle | sed -e 's/[^0-9\.]//g' | head -n1) echo "version_name=$VERSION_NAME" >> $FORGEJO_OUTPUT VERSION_CODE=$(grep 'versionCode .*' app/build.gradle | sed -e 's/[^0-9\.]//g' | head -n1) echo "version_code=$VERSION_CODE" >> $FORGEJO_OUTPUT working-directory: workdir - name: bump version id: bump uses: https://git.fucktheforce.de/actions/increment-semantic-version.git@1.2.3 with: current-version: "${{ steps.info.outputs.version_name }}" version-fragment: "${{ inputs.version_update }}" - name: create tag and update version run: | git tag "v${{ steps.info.outputs.version_name }}" NEXT_VERSION_CODE=$(( ${{ steps.info.outputs.version_code }} + 1 )) sed -i -e 's/versionName .*/versionName "${{ steps.bump.outputs.next-version }}"/g' app/build.gradle sed -i -e "s/versionCode .*/versionCode $NEXT_VERSION_CODE/g" app/build.gradle git add app/build.gradle git commit -m "update version info after creating tag" git push git push --tags working-directory: workdir env: GIT_AUTHOR_NAME: "${{ vars.GIT_AUTHOR_NAME }}" GIT_AUTHOR_EMAIL: "${{ vars.GIT_AUTHOR_EMAIL }}" EMAIL: "${{ vars.GIT_AUTHOR_EMAIL }}" ``` gradle filename should be a variable and adjusted according to this project
Author
Owner

done

done
Sign in to join this conversation.
No labels
update fork
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
thedevstack/PiratX#86
No description provided.