Glusk / sprouts

A multi-platform implementation of Sprouts, built with libGDX.
MIT License
1 stars 1 forks source link

Automate versioning and releases #161

Closed Glusk closed 4 years ago

Glusk commented 5 years ago

Resources:

Glusk commented 5 years ago

@rultor hello

rultor commented 5 years ago

@rultor hello

@glusk2 Hi there! I understand a few simple commands: "merge", "deploy", etc. This page explains them briefly. Any questions or bug reports are welcome. Have fun :)

Glusk commented 5 years ago

.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
Glusk commented 5 years ago

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
Glusk commented 5 years ago

Badge: DevOps By Rultor.com

Glusk commented 5 years ago

Gradle release plugin requires to have the version stored in gradle.properties

Glusk commented 5 years ago

Keeps failing with:

Execution failed for task ':sprouts:checkCommitNeeded'.
> You have uncommitted files:
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   M gradle.properties
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Glusk commented 5 years ago

It doesn't work! Still reports uncommited when trying to run the release plugin.

Glusk commented 5 years ago

I'm giving up on gradle-release plugin!

Glusk commented 5 years ago

Manually pick out gradle-release steps

  1. echo "$tag" | ./gradlew updateVersion
  2. git commit -am "$tag"

  1. # create a new tag for the latest commit
  2. echo "$tag-SNAPSHOT" | ./gradlew updateVersion
  3. 
    git commit -am "$tag-SNAPSHOT"
    Can't do this with rultor. Rultor tags the **last** commit.
Glusk commented 4 years ago

Rultor only pushes the release tag. Because it doesn't push to master, the version doesn't get updated.

Glusk commented 4 years ago

How about this: https://help.github.com/en/github/automating-your-workflow-with-github-actions/creating-a-docker-container-action ?

Glusk commented 4 years ago

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 }}
Glusk commented 4 years ago

Github, please release version: v0.9.2

Glusk commented 4 years ago

Github, please release version: v0.9.2

Glusk commented 4 years ago

Github, please release version: v0.9.2

Glusk commented 4 years ago

Github, please release version: v0.9.2

Glusk commented 4 years ago

Github, please release version: v0.9.2

Glusk commented 4 years ago

Github, please release version: v0.9.2

Glusk commented 4 years ago

Badge for the workflow (replace rultor badge with this one): Actions Status

Glusk commented 4 years ago

The release action should post a reply to the issue with some status info during the release.

Glusk commented 4 years ago

Github, please release version: v0.10.1

Glusk commented 4 years ago

Github, please release version: throwaway

rultor commented 4 years ago

@rultor hello

@glusk Hi there! I understand a few simple commands: "merge", "deploy", etc. This page explains them briefly. Any questions or bug reports are welcome. Have fun :)