Skip to content

Commit

Permalink
feat: add test release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu-xiaowei committed Dec 29, 2024
1 parent 61baa57 commit c4d8c57
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release Next Version
#on:
# workflow_dispatch:
# inputs:
# release_tag:
# description: 'Release Tag'
# required: true
# type: string
# release_code:
# description: 'Release Code'
# required: true
# type: string
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
# NEW_VERSION: ${{ github.event.inputs.release_tag }}
# NEW_VERSION_CODE: ${{ github.event.inputs.release_code }}
NEW_VERSION: 1.8.0
NEW_VERSION_CODE: 13
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: latex
fetch-depth: 0
token: ${{ secrets.PROJECT_TOKEN }}
- name: Modify for next release
run: |
cd react-native
npm i
chmod +x release.sh
./release.sh ${{ env.NEW_VERSION }} ${{ env.NEW_VERSION_CODE }}
git diff
git config user.name '${{ vars.USER_NAME }}'
git config user.email '${{ vars.USER_EMAIL }}'
git add .
git commit -m 'release: SwiftChat v${{ env.NEW_VERSION }}'
git push
git tag ${{ env.NEW_VERSION }}
git push origin ${{ env.NEW_VERSION }}
- name: Prepare release file
run: |
cd react-native/android
ls
./gradlew assembleRelease
cd app/build/outputs/apk/release
ls
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
name: "SwiftChat v${{ env.NEW_VERSION }}"
files: |
*.apk
tag_name: "${{ env.NEW_VERSION }}"
prerelease: false
generate_release_notes: true
9 changes: 9 additions & 0 deletions react-native/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ android {
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.apk')) {
def fileName = "SwiftChat.apk"
output.outputFileName = fileName
}
}
}
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions react-native/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

version="$1"
version_code="$2"
echo ${version}
echo ${version_code}
regex="[0-9]\+\.[0-9]\+\.[0-9]\+"
version_code_regex="[0-9]\+"

# modify react native project version
sed -i "s/\"version\": \"${regex}\"/\"version\": \"${version}\"/g" package.json

# modify android version
sed -i "s/versionCode ${version_code_regex}/versionCode ${version_code}/g" android/app/build.gradle
sed -i "s/versionName \"${regex}\"/versionName \"${version}\"/g" android/app/build.gradle

# modify iOS version
sed -i "s/MARKETING_VERSION = ${regex};/MARKETING_VERSION = ${version};/g" ios/SwiftChat.xcodeproj/project.pbxproj
sed -i "s/CURRENT_PROJECT_VERSION = ${version_code_regex};/CURRENT_PROJECT_VERSION = ${version_code};/g" ios/SwiftChat.xcodeproj/project.pbxproj

# modify README download link
sed -i "s/download\/${regex}\/SwiftChat.apk/download\/${version}\/SwiftChat.apk/g" ../README.md
sed -i "s/download\/${regex}\/SwiftChat.dmg/download\/${version}\/SwiftChat.dmg/g" ../README.md
sed -i "s/download\/${regex}\/SwiftChat.apk/download\/${version}\/SwiftChat.apk/g" ../README_CN.md
sed -i "s/download\/${regex}\/SwiftChat.dmg/download\/${version}\/SwiftChat.dmg/g" ../README_CN.md


0 comments on commit c4d8c57

Please sign in to comment.