From ca58dbfcece2b653b1b029e5bf3b70e0bdeab0e5 Mon Sep 17 00:00:00 2001 From: Ritesh Shukla Date: Sat, 31 May 2025 17:31:36 +0530 Subject: [PATCH] Fix (#392) Update CI workflows * add ai release notes to the release no new user features --------- Co-authored-by: Violet Caulfield --- .github/workflows/publish-beta.yml | 228 +++++++++++++++++++++++------ package.json | 4 +- 2 files changed, 182 insertions(+), 50 deletions(-) diff --git a/.github/workflows/publish-beta.yml b/.github/workflows/publish-beta.yml index 361f4382..85044c58 100644 --- a/.github/workflows/publish-beta.yml +++ b/.github/workflows/publish-beta.yml @@ -1,11 +1,96 @@ name: Publish Android APK and TestFlight Betas on: workflow_dispatch: + inputs: + build-platform: + description: 'Select the platform to build' + required: true + default: 'Both' + type: choice + options: + - Android + - iOS + - Both + + version-bump: + description: 'Version bump type' + required: true + default: 'No Bump' + type: choice + options: + - No Bump + - minor + - patch + - major jobs: - publish-beta: + publish-android: + if: ${{ github.event.inputs['build-platform'] == 'Android' || github.event.inputs['build-platform'] == 'Both' }} runs-on: macos-15 + outputs: + version: ${{ steps.setver.outputs.version }} steps: + - name: ๐Ÿ›’ Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.SIGNING_REPO_PAT }} + + - name: ๐Ÿ–ฅ Setup Node 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: ๐ŸŽ Run yarn init-android + run: yarn init-android + + - name: + Version Up + if: ${{ github.event.inputs['version-bump'] != 'No Bump' }} + run: yarn react-native bump-version --type ${{ github.event.inputs['version-bump'] }} + + - id: setver + run: echo "version=$(node -p -e "require('./package.json').version")" >> $GITHUB_OUTPUT + + + - name: ๐Ÿ’ฌ Echo package.json version to Github ENV + run: echo VERSION_NUMBER=$(node -p -e "require('./package.json').version") >> $GITHUB_ENV + + - name: ๐Ÿคซ Output TelemetryDeck Secrets to TelemetryDeck.json + run: | + echo "{" > telemetrydeck.json + echo "\"appID\": \"${{ secrets.TELEMETRYDECK_APPID }}\"," >> telemetrydeck.json + echo "\"clientUser\": \"anonymous\"," >> telemetrydeck.json + echo "\"app\": \"Jellify\"" >> telemetrydeck.json + echo "}" >> telemetrydeck.json + + + - name: ๐Ÿคซ Output Glitchtip Secrets to Glitchtip.json + run: | + echo "{" > glitchtip.json + echo "\"dsn\": \"${{ secrets.GLITCHTIP_DSN }}\"" >> glitchtip.json + echo "}" >> glitchtip.json + + - name: โœ… Validate Config Files + run: | + node -e "JSON.parse(require('fs').readFileSync('telemetrydeck.json'))" + node -e "JSON.parse(require('fs').readFileSync('glitchtip.json'))" + + - name: ๐Ÿš€ Run Android fastlane build + run: yarn fastlane:android:build + + - name: ๐Ÿ“ค Upload Android Artifacts + uses: actions/upload-artifact@v4 + with: + name: android-artifacts + path: ./android/app/build/outputs/apk/release/*.apk + + + publish-iOS: + if: ${{ github.event.inputs['build-platform'] == 'iOS' || github.event.inputs['build-platform'] == 'Both' }} + runs-on: macos-15 + outputs: + version: ${{ steps.setver.outputs.version }} + steps: + - name: ๐Ÿ›’ Checkout uses: actions/checkout@v4 with: @@ -19,8 +104,12 @@ jobs: - name: ๐ŸŽ Run yarn init-ios:new-arch run: yarn init-ios:new-arch - - name: โž• Version Up - run: yarn react-native bump-version --type patch + - name: + Version Up + if: ${{ github.event.inputs['version-bump'] != 'No Bump' }} + run: yarn react-native bump-version --type ${{ github.event.inputs['version-bump'] }} + + - id: setver + run: echo "version=$(node -p -e "require('./package.json').version")" >> $GITHUB_OUTPUT - name: ๐Ÿ’ฌ Echo package.json version to Github ENV run: echo VERSION_NUMBER=$(node -p -e "require('./package.json').version") >> $GITHUB_ENV @@ -44,12 +133,9 @@ jobs: echo "\"dsn\": \"${{ secrets.GLITCHTIP_DSN }}\"" >> glitchtip.json echo "}" >> glitchtip.json - - name: โœ… Validate TelemetryDeck.json + - name: โœ… Validate Config Files run: | node -e "JSON.parse(require('fs').readFileSync('telemetrydeck.json'))" - - - name: โœ… Validate Glitchtip.json - run: | node -e "JSON.parse(require('fs').readFileSync('glitchtip.json'))" - name: ๐Ÿš€ Run iOS fastlane build and publish to TestFlight @@ -60,63 +146,109 @@ jobs: MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} MATCH_REPO_PAT: "anultravioletaurora:${{ secrets.SIGNING_REPO_PAT }}" - - name: ๐Ÿš€ Run Android fastlane build - run: yarn fastlane:android:build + - name: ๐Ÿ“ค Upload iOS Artifact + uses: actions/upload-artifact@v4 + with: + name: ios-artifacts + path: ./ios/Jellify.ipa - - name: ๐Ÿ‘ฉโ€๐Ÿ’ป Configure Git - run: | - git config --global user.email "violet@cosmonautical.cloud" - git config --global user.name "anultravioletaurora" - git remote set-url origin https://x-access-token:${{ secrets.SIGNING_REPO_PAT }}@github.com/Jellify-Music/App.git + finalize-release: + needs: [publish-android, publish-ios] + runs-on: macos-15 + steps: + - name: ๐Ÿ›’ Checkout Repo + uses: actions/checkout@v4 + with: + token: ${{ secrets.SIGNING_REPO_PAT }} + - name: โฌ‡๏ธ Download Android Artifacts + if: ${{ github.event.inputs['build-platform'] == 'Android' || github.event.inputs['build-platform'] == 'Both' }} + uses: actions/download-artifact@v4 + with: + name: android-artifacts + path: artifacts/ - - name: ๐Ÿงน Clean up Glitchtip and TelemetryDeck files - run: | - git restore telemetrydeck.json - git restore glitchtip.json - - # Commit Fastlane Xcode build number increment - - name: ๐Ÿ”ข Commit changes for version increment - run: | - git add package.json - git add ios/Jellify.xcodeproj/project.pbxproj - git add android/app/build.gradle - git commit -m "[skip actions]" - git push origin main - + - name: โฌ‡๏ธ Download iOS Artifacts + if: ${{ github.event.inputs['build-platform'] == 'iOS' || github.event.inputs['build-platform'] == 'Both' }} + uses: actions/download-artifact@v4 + with: + name: ios-artifacts + path: artifacts/ + - name: ๐Ÿ”ข Set artifact version numbers run: | - # Create artifacts folder for uploading to release - mkdir artifacts + VERSION=${{ needs.publish-ios.outputs.version || needs.publish-android.outputs.version }} + mkdir final-artifacts - # Move the iOS IPA - mv ./ios/Jellify.ipa ./artifacts/Jellify-${{ env.VERSION_NUMBER }}.ipa + # Rename IPA + if [ -f artifacts/ios-artifacts/Jellify.ipa ]; then + cp artifacts/ios-artifacts/Jellify.ipa "final-artifacts/Jellify-${VERSION}.ipa" + fi - # Move and rename all android release APKs - for apk in ./android/app/build/outputs/apk/release/*.apk; do - filename=$(basename "$apk") - newname="Jellify-${{ env.VERSION_NUMBER }}-${filename}" - cp "$apk" "./artifacts/$newname" - done + # Rename APKs + if [ -d artifacts/android-artifacts ]; then + for apk in artifacts/android-artifacts/*.apk; do + filename=$(basename "$apk") + cp "$apk" "final-artifacts/Jellify-${VERSION}-${filename}" + done + fi - - name: ๐ŸŽ‰ Create Github release + - name: ๐Ÿ”ข Commit version bump if any + if: ${{ github.event.inputs['version-bump'] != 'No Bump' }} + run: | + git config --global user.name "anultravioletaurora" + git config --global user.email "violet@jellify.app" + git add package.json ios/Jellify.xcodeproj/project.pbxproj android/app/build.gradle || true + git commit -m "[skip actions] version bump" || echo "No changes to commit" + git push origin main + + - name: ๐Ÿง  Get commit messages for this release + id: commits + run: | + echo "messages<> $GITHUB_OUTPUT + git log --pretty=format:"- %s" $(git describe --tags --abbrev=0)..HEAD >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: โœจ Generate Release Notes with ChatGPT + id: ai_release_notes + run: | + RELEASE_BODY=$(curl -s https://api.openai.com/v1/chat/completions \ + -H "Authorization: Bearer ${{ secrets.OPENAI_API_KEY }}" \ + -H "Content-Type: application/json" \ + -d '{ + "model": "gpt-4", + "messages": [ + {"role": "system", "content": "You are a helpful assistant that writes concise and friendly mobile app release notes from commit messages."}, + {"role": "system", "content": "You are writing release notes for a mobile app called Jellify. The app is a music player that allows you to play music from your library and stream music from the internet."}, + {"role": "system", "content": "You are a music enthusiast and you love music related puns and jokes. You can lightly add a pun or joke to the release notes if it's relevant to the release."}, + {"role": "system", "content": "Release notes should be concise and helpful to any user of the app - regardless of their technical knowledge."}, + {"role": "system", "content": "Release notes should be written in a way that is easy to understand and follow."}, + {"role": "user", "content": "Write a release summary based on these commit messages:\n'"${{ steps.commits.outputs.messages }}"'"} + ], + "temperature": 0.7 + }' | jq -r '.choices[0].message.content') + + echo "release_notes<> $GITHUB_OUTPUT + echo "$RELEASE_BODY" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: ๐ŸŽ‰ Create Unified GitHub Release uses: ncipollo/release-action@v1 id: githubRelease with: - artifacts: "./artifacts/*" - name: ${{ env.VERSION_NUMBER }} - generateReleaseNotes: true + artifacts: ./final-artifacts/* + name: ${{ needs.publish-ios.outputs.version || needs.publish-android.outputs.version }} + tag: ${{ needs.publish-ios.outputs.version || needs.publish-android.outputs.version }} + body: ${{ steps.ai_release_notes.outputs.release_notes }} prerelease: true - tag: ${{ env.VERSION_NUMBER }} token: ${{ secrets.SIGNING_REPO_PAT }} - name: ๐Ÿ—ฃ๏ธ Notify on Discord run: | cd ios - bundle exec fastlane notifyOnDiscord + bundle install && bundle exec fastlane notifyOnDiscord cd .. - - env: + env: DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} - APP_VERSION: ${{ env.VERSION_NUMBER }} - release_url: ${{ steps.githubRelease.outputs.html_url }} + APP_VERSION: ${{ needs.publish-ios.outputs.version || needs.publish-android.outputs.version }} + release_url: ${{ steps.githubRelease.outputs.html_url }} \ No newline at end of file diff --git a/package.json b/package.json index 849c9216..a071d225 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "version": "0.12.29", "private": true, "scripts": { - "init-android": "yarn", + "init-android": "yarn install --network-concurrency 1", "init-ios": "yarn init-ios:new-arch", - "init-ios:new-arch": "yarn && yarn pod:install:new-arch", + "init-ios:new-arch": "yarn install --network-concurrency 1 && yarn pod:install:new-arch", "reinstall": "rm -rf ./node_modules && yarn install", "android": "react-native run-android", "ios": "react-native run-ios",