Skip to content

Commit 2240913

Browse files
authored
Merge pull request #484 from proyecto26/feature/semantic-release
feat(ci): automated release workflow with semantic versioning
2 parents c0f5257 + 67210c0 commit 2240913

7 files changed

Lines changed: 302 additions & 70 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
inputs:
9+
version_bump:
10+
description: 'Version bump type'
11+
required: true
12+
default: 'patch'
13+
type: choice
14+
options:
15+
- patch
16+
- minor
17+
- major
18+
release_notes:
19+
description: 'Additional release notes (optional)'
20+
required: false
21+
type: string
22+
23+
permissions:
24+
contents: write
25+
26+
jobs:
27+
release:
28+
name: Create Release
29+
runs-on: ubuntu-latest
30+
outputs:
31+
new_version: ${{ steps.version.outputs.new_version }}
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Get current version
39+
id: current
40+
run: |
41+
CURRENT=$(node -p "require('./package.json').version")
42+
echo "version=$CURRENT" >> $GITHUB_OUTPUT
43+
echo "Current version: $CURRENT"
44+
45+
- name: Determine version bump from commits
46+
id: bump
47+
run: |
48+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49+
echo "type=${{ inputs.version_bump }}" >> $GITHUB_OUTPUT
50+
else
51+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
52+
if [ -z "$LAST_TAG" ]; then RANGE="HEAD"; else RANGE="${LAST_TAG}..HEAD"; fi
53+
COMMITS=$(git log $RANGE --pretty=format:"%s" 2>/dev/null || echo "")
54+
if echo "$COMMITS" | grep -qiE "^(feat|feature)(\(.+\))?!:|BREAKING CHANGE"; then
55+
echo "type=major" >> $GITHUB_OUTPUT
56+
elif echo "$COMMITS" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
57+
echo "type=minor" >> $GITHUB_OUTPUT
58+
else
59+
echo "type=patch" >> $GITHUB_OUTPUT
60+
fi
61+
fi
62+
63+
- name: Calculate new version
64+
id: version
65+
run: |
66+
IFS='.' read -r MAJOR MINOR PATCH <<< "${{ steps.current.outputs.version }}"
67+
case "${{ steps.bump.outputs.type }}" in
68+
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
69+
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
70+
patch) PATCH=$((PATCH + 1)) ;;
71+
esac
72+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
73+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
74+
echo "New version: $NEW_VERSION"
75+
76+
- name: Generate changelog entry
77+
id: changelog
78+
run: |
79+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
80+
if [ -z "$LAST_TAG" ]; then RANGE="HEAD"; else RANGE="${LAST_TAG}..HEAD"; fi
81+
82+
TODAY=$(date +%Y-%m-%d)
83+
NEW_VERSION="${{ steps.version.outputs.new_version }}"
84+
ADDED="" CHANGED="" FIXED="" REMOVED=""
85+
86+
while IFS= read -r line; do
87+
HASH=$(echo "$line" | cut -d'|' -f1)
88+
MSG=$(echo "$line" | cut -d'|' -f2-)
89+
SHORT_HASH=$(echo "$HASH" | cut -c1-7)
90+
PR_NUM=$(echo "$MSG" | grep -oP '\(#\K[0-9]+(?=\))' | head -1)
91+
92+
if [ -n "$PR_NUM" ]; then
93+
ATTR="([#${PR_NUM}](https://github.com/proyecto26/react-native-inappbrowser/pull/${PR_NUM}))"
94+
else
95+
ATTR="([${SHORT_HASH}](https://github.com/proyecto26/react-native-inappbrowser/commit/${HASH}))"
96+
fi
97+
98+
CLEAN_MSG=$(echo "$MSG" | sed -E 's/^(feat|fix|perf|refactor|chore|docs|style|test|build|ci)(\([^)]*\))?(!)?:\s*//')
99+
CLEAN_MSG=$(echo "$CLEAN_MSG" | sed -E 's/\s*\(#[0-9]+\)\s*$//')
100+
101+
if echo "$MSG" | grep -qiE "^(feat|feature)(\(.+\))?:"; then
102+
ADDED="${ADDED}- ${CLEAN_MSG} ${ATTR}.\n"
103+
elif echo "$MSG" | grep -qiE "^fix(\(.+\))?:"; then
104+
FIXED="${FIXED}- ${CLEAN_MSG} ${ATTR}.\n"
105+
elif echo "$MSG" | grep -qiE "^(perf|refactor|chore|docs|style|build|ci)(\(.+\))?:"; then
106+
CHANGED="${CHANGED}- ${CLEAN_MSG} ${ATTR}.\n"
107+
elif echo "$MSG" | grep -qiE "^(revert)(\(.+\))?:"; then
108+
REMOVED="${REMOVED}- ${CLEAN_MSG} ${ATTR}.\n"
109+
else
110+
CHANGED="${CHANGED}- ${CLEAN_MSG} ${ATTR}.\n"
111+
fi
112+
done < <(git log $RANGE --pretty=format:"%H|%s" --no-merges 2>/dev/null)
113+
114+
if [ -n "${{ inputs.release_notes }}" ]; then
115+
ADDED="${ADDED}- ${{ inputs.release_notes }}\n"
116+
fi
117+
118+
BODY=""
119+
[ -n "$ADDED" ] && BODY="${BODY}### Added\n${ADDED}\n"
120+
[ -n "$CHANGED" ] && BODY="${BODY}### Changed\n${CHANGED}\n"
121+
[ -n "$FIXED" ] && BODY="${BODY}### Fixed\n${FIXED}\n"
122+
[ -n "$REMOVED" ] && BODY="${BODY}### Removed\n${REMOVED}\n"
123+
[ -z "$BODY" ] && BODY="### Changed\n- Release version ${NEW_VERSION}.\n"
124+
125+
echo -e "$BODY" > /tmp/release_body.md
126+
127+
# Update CHANGELOG.md
128+
PREV_VERSION="${{ steps.current.outputs.version }}"
129+
HEADER="## [${NEW_VERSION}] - ${TODAY}"
130+
LINK="[${NEW_VERSION}]: https://github.com/proyecto26/react-native-inappbrowser/compare/v${PREV_VERSION}...v${NEW_VERSION}"
131+
sed -i "/^## \[Unreleased\]/a\\\\n${HEADER}\\n" CHANGELOG.md
132+
sed -i "/^## \[${NEW_VERSION}\]/r /tmp/release_body.md" CHANGELOG.md
133+
sed -i "s|\[Unreleased\]: .*|[Unreleased]: https://github.com/proyecto26/react-native-inappbrowser/compare/v${NEW_VERSION}...HEAD|" CHANGELOG.md
134+
sed -i "/^\[Unreleased\]:/a ${LINK}" CHANGELOG.md
135+
136+
- name: Update version in package.json
137+
run: |
138+
# Use node to update version properly (preserves formatting)
139+
node -e "
140+
const pkg = require('./package.json');
141+
pkg.version = '${{ steps.version.outputs.new_version }}';
142+
require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
143+
"
144+
145+
- name: Commit version bump
146+
run: |
147+
git config --global user.name 'github-actions[bot]'
148+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
149+
git add -A
150+
git commit -m "chore(release): v${{ steps.version.outputs.new_version }}
151+
152+
- Updated package.json
153+
- Updated CHANGELOG.md"
154+
git tag "v${{ steps.version.outputs.new_version }}"
155+
git push origin main --follow-tags
156+
157+
- name: Create GitHub Release
158+
uses: softprops/action-gh-release@v2
159+
with:
160+
tag_name: v${{ steps.version.outputs.new_version }}
161+
name: Release ${{ steps.version.outputs.new_version }}
162+
body_path: /tmp/release_body.md
163+
draft: false
164+
prerelease: false
165+
166+
publish-npm:
167+
name: Publish to npm
168+
needs: release
169+
runs-on: ubuntu-latest
170+
if: needs.release.outputs.new_version != ''
171+
steps:
172+
- uses: actions/checkout@v4
173+
with:
174+
ref: main
175+
176+
- name: Pull latest (includes version bump commit)
177+
run: git pull origin main
178+
179+
- name: Setup Node.js
180+
uses: actions/setup-node@v4
181+
with:
182+
node-version: '20'
183+
registry-url: 'https://registry.npmjs.org'
184+
185+
- name: Publish to npm
186+
run: npm publish
187+
env:
188+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

‎README.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ Methods | Action
145145
`openAuth` | Opens the url with Safari in a modal on iOS using **SFAuthenticationSession/ASWebAuthenticationSession**, and Chrome in a new custom tab on Android. On iOS, the user will be asked whether to allow the app to authenticate using the given url **(OAuth flow with deep linking redirection)**.
146146
`closeAuth` | Dismisses the current authentication session.
147147
`isAvailable` | Detect if the device supports this plugin.
148+
`onStart` | Initialize a bound background service so the application can communicate its intention to the browser. After the service is connected, the client can be used to Warms up the browser to make navigation faster and indicates that a given URL may be loaded in the future. - Android Only.
149+
`warmup` | Warm up the browser process - Android Only.
150+
`mayLaunchUrl` | Tells the browser of a likely future navigation to a URL. The most likely URL has to be specified first. Optionally, a list of other likely URLs can be provided. They are treated as less likely than the first one, and have to be sorted in decreasing priority order. These additional URLs may be ignored. All previous calls to this method will be deprioritized - Android Only.
148151
149152
### iOS Options
150153
@@ -349,7 +352,7 @@ import { InAppBrowser } from 'react-native-inappbrowser-reborn'
349352
import { getDeepLink } from './utilities'
350353
...
351354
async onLogin() {
352-
const deepLink = getDeepLink('callback)
355+
const deepLink = getDeepLink('callback')
353356
const url = `https://my-auth-login-page.com?redirect_uri=${deepLink}`
354357
try {
355358
if (await InAppBrowser.isAvailable()) {
@@ -524,11 +527,9 @@ Support this project with your organization. Your logo will show up here with a
524527
I believe in Unicorns 🦄
525528
Support [me](http://www.paypal.me/jdnichollsc/2), if you do too.
526529

527-
Donate **Ethereum**, **ADA**, **BNB**, **SHIBA**, **USDT**, **DOGE**:
530+
Donate **Ethereum**, **ADA**, **BNB**, **SHIBA**, **USDT/USDC**, **DOGE**, etc:
528531

529-
![Wallet address](https://user-images.githubusercontent.com/2154886/123501719-84bf1900-d60c-11eb-882c-98a499cea323.png)
530-
531-
> Wallet address: 0x3F9fA8021B43ACe578C2352861Cf335449F33427
532+
> Wallet address: jdnichollsc.eth
532533
533534
Please let us know your contributions! 🙏
534535

‎android/build.gradle‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def DEFAULT_MIN_SDK_VERSION = 16
2727
def DEFAULT_TARGET_SDK_VERSION = 31
2828

2929
android {
30+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
31+
if (agpVersion >= 7) {
32+
namespace 'com.proyecto26.inappbrowser'
33+
}
3034
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
3135
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
3236
defaultConfig {
@@ -51,19 +55,25 @@ repositories {
5155
dependencies {
5256
implementation fileTree(dir: 'libs', include: ['*.jar'])
5357
implementation 'com.facebook.react:react-native:+'
54-
implementation 'org.greenrobot:eventbus:3.1.0'
58+
def eventbusVersion = safeExtGet('eventbus', safeExtGet('eventbus', '3.3.1'))
59+
implementation "org.greenrobot:eventbus:$eventbusVersion"
5560
def supportLibVersion = safeExtGet('supportLibVersion', safeExtGet('supportVersion', null))
56-
def androidXVersion = safeExtGet('androidXVersion', null)
57-
if (supportLibVersion && androidXVersion == null) {
61+
def androidXAnnotationVersion = safeExtGet('androidXAnnotationVersion', null)
62+
def androidXBrowserVersion = safeExtGet('androidXBrowserVersion', null)
63+
if (supportLibVersion) {
5864
implementation "com.android.support:support-annotations:$supportLibVersion"
5965
implementation "com.android.support:customtabs:$supportLibVersion"
6066
} else {
61-
def defaultAndroidXVersion = "1.+"
62-
if (androidXVersion == null) {
63-
androidXVersion = defaultAndroidXVersion
67+
def defaultAndroidXAnnotationVersion = "1.5.+"
68+
def defaultAndroidXBrowserVersion = "1.4.+"
69+
if (androidXAnnotationVersion == null) {
70+
androidXAnnotationVersion = defaultAndroidXAnnotationVersion
71+
}
72+
if (androidXBrowserVersion == null) {
73+
androidXBrowserVersion = defaultAndroidXBrowserVersion
6474
}
65-
def androidXAnnotation = safeExtGet('androidXAnnotation', androidXVersion)
66-
def androidXBrowser = safeExtGet('androidXBrowser', androidXVersion)
75+
def androidXAnnotation = safeExtGet('androidXAnnotation', androidXAnnotationVersion)
76+
def androidXBrowser = safeExtGet('androidXBrowser', androidXBrowserVersion)
6777
implementation "androidx.annotation:annotation:$androidXAnnotation"
6878
implementation "androidx.browser:browser:$androidXBrowser"
6979
}

‎android/src/main/AndroidManifest.xml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.proyecto26.inappbrowser">
3+
package="com.proyecto26.inappbrowser">
44

55
<uses-permission android:name="android.permission.INTERNET" />
66

77
<application>
8-
<activity
9-
android:name=".ChromeTabsManagerActivity"
10-
android:exported="false">
8+
<activity android:name=".ChromeTabsManagerActivity"
9+
android:exported="false">
1110
</activity>
1211
</application>
1312
<queries>

0 commit comments

Comments
 (0)