Skip to content

Commit

Permalink
Change release GH actions to create and release from release branch (#…
Browse files Browse the repository at this point in the history
…326)

## Goal

Create a release branch to make any version-specific modifications on and make the release from there. The version number of the SDK will incremented when the release branch is cut, and commits after that will be de facto in the next release. The Swazzler will be updated in the pre-release workflow as it does before.

If there are additional changes that need to go into the release branch, they can be done first in master, then cherrypicked into the release branch.

For hotfixes, the same cherrypicking process will be done, but we will need to add additional GH Actions to ensure to automate the release.
  • Loading branch information
bidetofevil committed Jan 30, 2024
1 parent 223b8fb commit d24effb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
39 changes: 19 additions & 20 deletions .github/workflows/pre-release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ 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 for it 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:
Expand All @@ -31,9 +34,11 @@ jobs:
echo $mavenSigningKeyRingFileEncoded | base64 -di > "$RUNNER_TEMP"/keystore/2DE631C1.gpg
echo "mavenSigningKeyRingFile=$RUNNER_TEMP/keystore/2DE631C1.gpg" >> $GITHUB_ENV
- name: Checkout Branch
- name: Create and Checkout Branch
uses: actions/checkout@v3
with:
run: |
git checkout -b release/${{ github.event.inputs.version_to_release }}
fetch-depth: 0
token: ${{ secrets.CD_GITHUB_TOKEN }}

Expand Down Expand Up @@ -83,12 +88,20 @@ jobs:
- name: Gradlew Pre-Release
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 add gradle.properties
git commit -m "CI/CD: change version to be released: ${{ github.event.inputs.current_version }}"
git commit -m "CI/CD: change version to be released: ${{ github.event.inputs.version_to_release }}.0"
git push
./gradlew clean publishReleasePublicationToSonatype closeSonatypeStagingRepository -Dorg.gradle.parallel=false --stacktrace
- name: Set next SDK 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: Checkout Swazzler
uses: actions/checkout@v3
with:
Expand All @@ -100,7 +113,7 @@ jobs:
- name: Swazzler Release
run: |
cd ./embrace-swazzler3
./gradlew clean release -Dorg.gradle.parallel=false -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ github.event.inputs.current_version }} -Prelease.newVersion=${{ github.event.inputs.next_version }}-SNAPSHOT --stacktrace
./gradlew clean release -Dorg.gradle.parallel=false -Prelease.useAutomaticVersion=true -Prelease.pushReleaseVersionBranch=release/${{ github.event.inputs.version_to_release }} -Prelease.releaseVersion=${{ github.event.inputs.version_to_release }}.0 -Prelease.newVersion=${{ github.event.inputs.next_version }}-SNAPSHOT --stacktrace
- name: Cleanup Gradle Cache
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
Expand All @@ -109,17 +122,3 @@ jobs:
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
# measure-sdk-size:
# uses: embrace-io/android-size-measure/.github/workflows/analyze-sdk-size.yml@main
# needs: release
# with:
# sdk_version: ${{ github.event.inputs.current_version }}
# token: ${{ secrets.CD_GITHUB_TOKEN }}
#
# measure-startup-time:
# uses: embrace-io/android-sdk-benchmark/.github/workflows/macrobenchmark.yml@main
# needs: release
# with:
# sdk_version: ${{ github.event.inputs.current_version }}
# token: ${{ secrets.CD_GITHUB_TOKEN }}
25 changes: 11 additions & 14 deletions .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ env:
on:
workflow_dispatch:
inputs:
next_version:
description: 'Next Version (Do NOT include -SNAPSHOT, will be added automatically)'
version_to_release:
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
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:
Expand All @@ -28,6 +32,7 @@ jobs:
- name: Checkout Branch
uses: actions/checkout@v3
with:
ref: release/${{ github.event.inputs.version_to_release }}
fetch-depth: 0
token: ${{ secrets.CD_GITHUB_TOKEN }}

Expand Down Expand Up @@ -56,24 +61,16 @@ jobs:
mv .docs-newly-generated docs
date > docs/version.txt
echo ${{ github.sha }} >> docs/version.txt
echo ${{ github.event.release.tag_name }} >> 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.release.tag_name }}' 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 }})
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 }}"}'
- name: Set next SDK version
- name: Record SDK Version History (${{ github.event.inputs.version_to_release }}.${{ github.event.inputs.patch_version_of_release }})
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: Cleanup Gradle Cache
# Based on https://docs.github.com/en/actions/guides/building-and-testing-java-with-gradle#caching-dependencies
Expand Down

0 comments on commit d24effb

Please sign in to comment.