Skip to content

Commit

Permalink
Create patch workflow (#354)
Browse files Browse the repository at this point in the history
## Goal

Workflow to create a patch RC based on an existing release branch
  • Loading branch information
bidetofevil committed Feb 2, 2024
1 parent d6e8e59 commit 7e1886a
Showing 1 changed file with 128 additions and 0 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/pre-patch-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Patch - Create Release Candidate

env:
SONATYPE_USERNAME: embrace-io
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_QA_USER: github
MAVEN_QA_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
mavenSigningKeyId: ${{ secrets.MAVEN_ANDROID_SIGNING_KEY }}
mavenSigningKeyRingFileEncoded: ${{ secrets.MAVEN_ANDROID_GPG_KEY }}
mavenSigningKeyPassword: ${{ secrets.MAVEN_ANDROID_SIGNING_PASSWORD }}

on:
workflow_dispatch:
inputs:
version_to_patch:
description: 'Version to patch. Specify <major.minor> only, e.g. 6.3'
required: true
patch_number:
description: 'Patch number. e.g. for 6.3.1, use "1"'
default: '1'
required: true
next_patch_number:
description: 'Next patch number. e.g. for 6.3.2, use "2"'
default: '2'
required: true

jobs:
release:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
matrix:
jdk-version: ["11"]
ndk-version: ["21.4.7075529"]
steps:
- name: Decode Keystore
run: |
mkdir "$RUNNER_TEMP"/keystore
echo $mavenSigningKeyRingFileEncoded | base64 -di > "$RUNNER_TEMP"/keystore/2DE631C1.gpg
echo "mavenSigningKeyRingFile=$RUNNER_TEMP/keystore/2DE631C1.gpg" >> $GITHUB_ENV
- name: Configure git
run: |
git config --global user.name 'embrace-ci[bot]'
git config --global user.email '[email protected]'
git config --global url."https://${{ secrets.CD_GITHUB_USER }}:${{ secrets.CD_GITHUB_TOKEN }}@github.com".insteadOf "https://github.com"
- name: Checkout SDK
with:
ref: release/${{ github.event.inputs.version_to_patch }}
token: ${{ secrets.CD_GITHUB_TOKEN }}

- uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-gradle-jdk${{ matrix.jdk-version }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle
- name: Install JDK ${{ matrix.jdk-version }}
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: ${{ matrix.jdk-version }}

- name: Setup NDK ${{ matrix.ndk-version }}
run: |
export ANDROID_ROOT=/usr/local/lib/android
export ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
export ANDROID_NDK_ROOT=${ANDROID_SDK_ROOT}/ndk-bundle
ln -sfn $ANDROID_SDK_ROOT/ndk/${{ matrix.ndk-version }} $ANDROID_NDK_ROOT
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Patch Pre-Release - Publish and close Sonatype repository
run: |
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.version_to_patch }}.${{ github.event.inputs.patch_number }}#" gradle.properties
git commit -m "CI/CD: change patch version to be released: ${{ github.event.inputs.version_to_patch }}.${{ github.event.inputs.patch_number }}"
git push
./gradlew clean check publishReleasePublicationToSonatype closeSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace
- name: Archive Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: android-sdk-test-results
path: embrace-android-sdk/build/reports/tests/

- name: Set Next Patch Version
run: |
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.version_to_patch }}.${{ github.event.inputs.next_patch_number }}-SNAPSHOT#" gradle.properties
git add gradle.properties
git commit -m "CI/CD: set next version: ${{ github.event.inputs.version_to_patch }}.${{ github.event.inputs.next_patch_number }}"
git push
- name: Checkout Swazzler
uses: actions/checkout@v4
with:
repository: embrace-io/embrace-swazzler3
ref: release/${{ github.event.inputs.version_to_patch }}
token: ${{ secrets.CD_GITHUB_TOKEN }}

- name: Swazzler Patch Pre-Release - Publish and Close repository
run: |
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.version_to_patch }}.${{ github.event.inputs.patch_number }}#" gradle.properties
git commit -m "CI/CD: change version to be released: ${{ github.event.inputs.version_to_patch }}.${{ github.event.inputs.patch_number }}"
git push
./gradlew clean check publishToSonatype closeSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace
- name: Set Next Swazzler Version
run: |
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.version_to_patch }}.${{ github.event.inputs.next_patch_number }}-SNAPSHOT#" gradle.properties
git add gradle.properties
git commit -m "CI/CD: set next version: ${{ github.event.inputs.version_to_patch }}.${{ github.event.inputs.next_patch_number }}"
git push
- name: Cleanup Gradle Cache
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties

0 comments on commit 7e1886a

Please sign in to comment.