Skip to content

Commit

Permalink
Create release branch to build release (#338)
Browse files Browse the repository at this point in the history
## Goal

Modify release workflows to create a release branch on which release specific changes will be made. Added a test workflow to test the branch creation to verify that it will actually work.
  • Loading branch information
bidetofevil committed Feb 2, 2024
1 parent 1a09505 commit d6e8e59
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 38 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/create-release-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Test - Cut Release Branch

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_release:
description: 'Version to release. Specify <major.minor> only, without the patch number, e.g. 6.3. A new branch called "release/<version>" will be created where the release-specific changes will be committed.'
required: true
next_version:
description: 'Next Version. Specify <major.minor.patch>, e.g. 6.4.0 (Do NOT include -SNAPSHOT, will be added automatically)'
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
uses: actions/checkout@v4
with:
ref: master
token: ${{ secrets.CD_GITHUB_TOKEN }}

- name: Create Release Branch "release/${{ github.event.inputs.version_to_release }}"
run: |
git checkout -b release/${{ github.event.inputs.version_to_release }}
- 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: Set Release Version
run: |
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.version_to_release }}.0#" gradle.properties
git commit -m "CI/CD: change version to be released: ${{ github.event.inputs.version_to_release }}.0"
git push
- 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: Checkout Swazzler
uses: actions/checkout@v4
with:
repository: embrace-io/embrace-swazzler3
ref: master
token: ${{ secrets.CD_GITHUB_TOKEN }}

- name: Create Swazzler Release Branch "release/${{ github.event.inputs.version_to_release }}"
run: |
git checkout -b release/${{ github.event.inputs.version_to_release }}
- name: Set Release Version
run: |
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.version_to_release }}.0#" gradle.properties
git commit -m "CI/CD: change version to be released: ${{ github.event.inputs.version_to_release }}.0"
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
52 changes: 45 additions & 7 deletions .github/workflows/pre-release-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pre-Release for Smoke
name: Release - Cut Release Branch and Create Release Candidate

env:
SONATYPE_USERNAME: embrace-io
Expand All @@ -12,12 +12,16 @@ env:
on:
workflow_dispatch:
inputs:
current_version:
description: 'Version to release'
version_to_release:
description: 'Version to release. Specify <major.minor> only, without the patch number, e.g. 6.3. A new branch called "release/<version>" will be created where the release-specific changes will be committed.'
required: true
next_version:
description: 'Next Version. Specify <major.minor.patch>, e.g. 6.4.0 (Do NOT include -SNAPSHOT, will be added automatically)'
required: true

jobs:
release:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -30,12 +34,22 @@ jobs:
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
uses: actions/checkout@v4
with:
ref: e9fbe5bd4a8aeb0a618487b3494e3f7f1f399a4d
ref: master
token: ${{ secrets.CD_GITHUB_TOKEN }}

- name: Create Release Branch "release/${{ github.event.inputs.version_to_release }}"
run: |
git checkout -b release/${{ github.event.inputs.version_to_release }}
- uses: actions/cache@v4
with:
path: |
Expand Down Expand Up @@ -63,9 +77,11 @@ jobs:
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: SDK Pre-Release - Publish and Close sonatype repository
- name: SDK Pre-Release - Publish and close Sonatype repository
run: |
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.current_version }}#" gradle.properties
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.version_to_release }}.0#" gradle.properties
git commit -m "CI/CD: change version to be released: ${{ github.event.inputs.version_to_release }}.0"
git push
./gradlew clean check publishReleasePublicationToSonatype closeSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace
- name: Archive Test Results
Expand All @@ -75,18 +91,40 @@ jobs:
name: android-sdk-test-results
path: embrace-android-sdk/build/reports/tests/

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

- name: Create Swazzler Release Branch "release/${{ github.event.inputs.version_to_release }}"
run: |
git checkout -b release/${{ github.event.inputs.version_to_release }}
- name: Swazzler Pre-Release - Publish and Close repository
run: |
sed -i -r "s#version = ([^\']+)#version= ${{ github.event.inputs.current_version }}#" gradle.properties
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.version_to_release }}.0#" gradle.properties
git commit -m "CI/CD: change version to be released: ${{ github.event.inputs.version_to_release }}.0"
git push
./gradlew clean check publishToSonatype closeSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace
- name: Set Next Swazzler Version
run: |
git checkout master
sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.next_version }}.0-SNAPSHOT#" gradle.properties
git add gradle.properties
git commit -m "CI/CD: set next version: ${{ github.event.inputs.next_version }}.0-SNAPSHOT"
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.
Expand Down
51 changes: 20 additions & 31 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Release - Release RC and Update Documentation

env:
SONATYPE_USERNAME: embrace-io
Expand All @@ -13,26 +13,33 @@ on:
workflow_dispatch:
inputs:
version_to_release:
description: 'Version to be released.'
description: 'SDK version this workflow run will release. Specify <major.minor> only, without the patch number, e.g. 6.3. It will use the branch "release/<version>".'
required: true
next_version:
description: 'Next Version (Do NOT include -SNAPSHOT, will be added automatically)'
patch_version_of_release:
description: 'The patch version for this release, i.e. the third number per semantic versioning <major.minor.patch>. If it is not a hotfix, use the default of 0'
required: true
default: '0'

jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
jdk-version: ["11"]
ndk-version: ["21.4.7075529"]
steps:
- name: Checkout Branch
- name: Checkout SDK
uses: actions/checkout@v4
with:
ref: e9fbe5bd4a8aeb0a618487b3494e3f7f1f399a4d
ref: release/${{ github.event.inputs.version_to_release }}
fetch-depth: 0
token: ${{ secrets.CD_GITHUB_TOKEN }}

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Gradlew Release SDK to maven central
- name: Gradlew Release SDK to Maven Central
run: |
./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace
Expand All @@ -53,49 +60,31 @@ jobs:
mv .docs-newly-generated docs
date > docs/version.txt
echo ${{ github.sha }} >> docs/version.txt
echo ${{ github.event.inputs.version_to_release }} >> docs/version.txt
echo ${{ github.event.inputs.version_to_release }}.${{ github.event.inputs.patch_version_of_release }} >> docs/version.txt
git add -f docs
git config --global user.name "embrace-ci"
git config --global user.email "[email protected]"
git commit --allow-empty --message 'CI/CD: Automatically generated documentation for ${{ github.event.inputs.version_to_release }}' docs/
git commit --allow-empty --message 'CI/CD: Automatically generated documentation for ${{ github.event.inputs.version_to_release }}.${{ github.event.inputs.patch_version_of_release }}' docs/
git push --force origin gh-pages
- name: Record SDK Version History (${{ github.event.inputs.current_version }})
- name: Record SDK Version History (${{ github.event.inputs.version_to_release }}.${{ github.event.inputs.patch_version_of_release }})
run: |
curl -X POST ${{ vars.SDK_VERSION_URL }}/android/version/ -H 'X-Embrace-CI: ${{ secrets.SDK_VERSION_TOKEN }}' -H 'Content-Type: application/json' -d '{"version": "${{ github.event.inputs.current_version }}"}'
# Not needed for now. but we will keep it.
# - name: Set next SDK version to remote
# run: |
# git checkout master
# sed -i -r "s#version = ([^\']+)#version = ${{ github.event.inputs.next_version }}-SNAPSHOT#" gradle.properties
# git add gradle.properties
# git commit -m "CI/CD: set next version: ${{ github.event.inputs.next_version }}"
# git push
curl -X POST ${{ vars.SDK_VERSION_URL }}/android/version/ -H 'X-Embrace-CI: ${{ secrets.SDK_VERSION_TOKEN }}' -H 'Content-Type: application/json' -d '{"version": "${{ github.event.inputs.version_to_release }}.${{ github.event.inputs.patch_version_of_release }}"}'
- name: Checkout Swazzler
uses: actions/checkout@v4
with:
repository: embrace-io/embrace-swazzler3
ref: master
ref: release/${{ github.event.inputs.version_to_release }}
token: ${{ secrets.CD_GITHUB_TOKEN }}

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

- name: Gradlew Release Swazzler to maven central
- name: Gradlew Release Swazzler to Maven Central
run: |
./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace
# Not needed for now. but we will keep it.
# - name: Set next Swazzler version
# run: |
# git checkout master
# sed -i -r "s#version= ([^\']+)#version = ${{ github.event.inputs.next_version }}-SNAPSHOT#" gradle.properties
# git add gradle.properties
# git commit -m "CI/CD: set next version: ${{ github.event.inputs.next_version }}"
# 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.
Expand Down

0 comments on commit d6e8e59

Please sign in to comment.