-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prep-release automation and scripts
- Loading branch information
crow
committed
Dec 9, 2024
1 parent
acb0976
commit 7ef4929
Showing
3 changed files
with
184 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: Prepare Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
react_native_version: | ||
description: 'React Native Version (x.y.z)' | ||
required: true | ||
pattern: '^\d+\.\d+\.\d+$' | ||
proxy_version: | ||
description: 'Airship Framework Proxy Version (x.y.z)' | ||
required: true | ||
pattern: '^\d+\.\d+\.\d+$' | ||
ios_version: | ||
description: 'iOS SDK Version (x.y.z)' | ||
required: false | ||
pattern: '^\d+\.\d+\.\d+$' | ||
android_version: | ||
description: 'Android SDK Version (x.y.z)' | ||
required: false | ||
pattern: '^\d+\.\d+\.\d+$' | ||
draft: | ||
description: 'Create as draft PR' | ||
type: boolean | ||
default: false | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
prepare-release: | ||
runs-on: macos-latest | ||
timeout-minutes: 15 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Run Updates | ||
run: | | ||
./scripts/update_version.sh "${{ github.event.inputs.react_native_version }}" || exit 1 | ||
./scripts/update_proxy_version.sh "${{ github.event.inputs.proxy_version }}" || exit 1 | ||
if [ -n "${{ github.event.inputs.ios_version }}" ] && [ -n "${{ github.event.inputs.android_version }}" ]; then | ||
./scripts/update_changelog.sh "${{ github.event.inputs.react_native_version }}" "${{ github.event.inputs.proxy_version }}" "${{ github.event.inputs.ios_version }}" "${{ github.event.inputs.android_version }}" || exit 1 | ||
fi | ||
- name: Verify Changes | ||
id: verify | ||
run: | | ||
CHANGED_FILES=$(git diff --name-only) | ||
if [ -z "$CHANGED_FILES" ]; then | ||
echo "No files were changed!" | ||
exit 1 | ||
fi | ||
echo "Changed files:" | ||
echo "$CHANGED_FILES" | ||
echo "changed_files<<EOF" >> $GITHUB_OUTPUT | ||
echo "$CHANGED_FILES" >> $GITHUB_OUTPUT | ||
echo "EOF" >> $GITHUB_OUTPUT | ||
- name: Create Pull Request | ||
id: create-pr | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: | | ||
Release ${{ github.event.inputs.react_native_version }} | ||
title: "Release ${{ github.event.inputs.react_native_version }}" | ||
body: | | ||
- Framework Proxy: ${{ github.event.inputs.proxy_version }} | ||
- iOS SDK: ${{ github.event.inputs.ios_version }} | ||
- Android SDK: ${{ github.event.inputs.android_version }} | ||
## Changed Files: | ||
``` | ||
${{ steps.verify.outputs.changed_files }} | ||
``` | ||
branch: release-${{ github.event.inputs.react_native_version }} | ||
base: main | ||
labels: | | ||
release | ||
automated pr | ||
draft: ${{ github.event.inputs.draft }} | ||
delete-branch: true | ||
|
||
- name: Handle Success | ||
if: success() && steps.create-pr.outputs.pull-request-number | ||
run: | | ||
echo "Pull request created successfully" | ||
echo "PR Number: ${{ steps.create-pr.outputs.pull-request-number }}" | ||
echo "PR URL: ${{ steps.create-pr.outputs.pull-request-url }}" | ||
- name: Slack Notification (Success) | ||
if: success() && steps.create-pr.outputs.pull-request-number | ||
uses: homoluctus/slatify@master | ||
with: | ||
type: success | ||
job_name: ":tada: React Native plugin release pull request generated :tada:" | ||
message: "@mobile-team A new React Native plugin release pull request for (v${{ github.event.inputs.react_native_version }}) is ready! :rocket:" | ||
url: ${{ secrets.MOBILE_SLACK_WEBHOOK }} | ||
|
||
- name: Handle Failure | ||
if: failure() | ||
run: | | ||
echo "::error::Release preparation failed. Please check the logs above for details." | ||
exit 1 | ||
- name: Slack Notification (Failure) | ||
if: failure() | ||
uses: homoluctus/slatify@master | ||
with: | ||
type: failure | ||
job_name: ":disappointed: React Native Plugin Release Failed :disappointed:" | ||
message: "@crow The release preparation failed. Please check the workflow logs. :sob:" | ||
url: ${{ secrets.MOBILE_SLACK_WEBHOOK }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
set -e | ||
set -x | ||
|
||
SCRIPT_DIRECTORY="$(dirname "$0")" | ||
ROOT_PATH=$SCRIPT_DIRECTORY/../ | ||
|
||
RN_VERSION=$1 | ||
PROXY_VERSION=$2 | ||
IOS_VERSION=$3 | ||
ANDROID_VERSION=$4 | ||
|
||
if [ -z "$RN_VERSION" ] || [ -z "$PROXY_VERSION" ]; then | ||
echo "Error: React Native and Proxy versions are required" | ||
exit 1 | ||
fi | ||
|
||
RELEASE_DATE=$(date +"%B %-d, %Y") | ||
|
||
# Create changelog entry | ||
NEW_ENTRY="## Version $RN_VERSION - $RELEASE_DATE\n\n" | ||
|
||
if [ -n "$IOS_VERSION" ] && [ -n "$ANDROID_VERSION" ]; then | ||
NEW_ENTRY+="Minor release that updates to latest SDK versions.\n\n" | ||
NEW_ENTRY+="### Changes\n" | ||
NEW_ENTRY+="- Updated Android SDK to $ANDROID_VERSION\n" | ||
NEW_ENTRY+="- Updated iOS SDK to $IOS_VERSION\n" | ||
NEW_ENTRY+="- Updated airship-mobile-framework-proxy to $PROXY_VERSION" | ||
else | ||
NEW_ENTRY+="Minor release that updates the airship-mobile-framework-proxy.\n\n" | ||
NEW_ENTRY+="### Changes\n" | ||
NEW_ENTRY+="- Updated airship-mobile-framework-proxy to $PROXY_VERSION" | ||
fi | ||
|
||
# Create temporary file with new content | ||
TEMP_FILE=$(mktemp) | ||
|
||
# Add the header line | ||
echo "# React Native Module Changelog" > "$TEMP_FILE" | ||
echo -e "\n$NEW_ENTRY\n" >> "$TEMP_FILE" | ||
|
||
# Append the rest of the existing changelog (skipping the header) | ||
tail -n +2 "$ROOT_PATH/CHANGELOG.md" >> "$TEMP_FILE" | ||
|
||
# Replace original file with new content | ||
mv "$TEMP_FILE" "$ROOT_PATH/CHANGELOG.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
|
||
SCRIPT_DIRECTORY="$(cd "$(dirname "$0")" && pwd)" | ||
ROOT_PATH="$SCRIPT_DIRECTORY/.." | ||
|
||
PROXY_VERSION="$1" | ||
if [ -z "$PROXY_VERSION" ]; then | ||
echo "No proxy version supplied" | ||
exit 1 | ||
fi | ||
|
||
# Update Android gradle.properties | ||
sed -i.bak -E "s/(Airship_airshipProxyVersion=)([^$]*)/\1$PROXY_VERSION/" "$ROOT_PATH/android/gradle.properties" | ||
|
||
# Update iOS podspec | ||
sed -i.bak -E "s/(s\.dependency *\"AirshipFrameworkProxy\", *\")([^\"]*)(\")/\1$PROXY_VERSION\3/" "$ROOT_PATH/react-native-airship.podspec" | ||
|
||
find "$ROOT_PATH" -name "*.bak" -delete |