Release #23
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
name: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
channel: | |
description: "Release channel: prod, beta, or alpha" | |
required: true | |
default: "prod" | |
jobs: | |
test: | |
uses: ./.github/workflows/test.yaml | |
bump_submodule: | |
uses: ./.github/workflows/bump_submodule.yaml | |
prepare_release: | |
runs-on: ubuntu-latest | |
outputs: | |
build_name: ${{ steps.set-env.outputs.build_name }} | |
build_number: ${{ steps.set-env.outputs.build_number }} | |
release_channel: ${{ steps.set-env.outputs.release_channel }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Git | |
run: | | |
git config --global user.email "49079695+FauconSpartiate@users.noreply.github.com" | |
git config --global user.name "Faucon" | |
- name: Set environment variables | |
id: set-env | |
run: | | |
fullVersion=$(grep -i -e "version: " pubspec.yaml) | |
BUILD_NAME=$(echo $fullVersion | cut -d " " -f 2 | cut -d "+" -f 1) | |
BUILD_NUMBER=$((${GITHUB_RUN_NUMBER} + 500)) | |
RELEASE_CHANNEL=${{ github.event.inputs.channel }} | |
echo "BUILD_NAME=$BUILD_NAME" >> $GITHUB_ENV | |
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV | |
echo "RELEASE_CHANNEL=$RELEASE_CHANNEL" >> $GITHUB_ENV | |
echo "::set-output name=build_name::$BUILD_NAME" | |
echo "::set-output name=build_number::$BUILD_NUMBER" | |
echo "::set-output name=release_channel::$RELEASE_CHANNEL" | |
- name: Check if version is used | |
run: | | |
if [ $(git tag -l "${{ env.BUILD_NAME }}") ]; then | |
echo "Version ${{ env.BUILD_NAME }} already exists" | |
exit 1 | |
fi | |
- name: Update Changelog | |
run: | | |
# Get the release changelog | |
changelog_file="CHANGELOG.md" | |
CHANGELOG=$(sed -n "/\[${{ env.BUILD_NAME }}\]/,/\[.*\] -/p" $changelog_file | sed '$d' | sed '$d' | sed '$s/\\n$//') | |
# echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV | |
STRIPPED_CHANGELOG=$(echo "$CHANGELOG" | sed '1s/^...//; 3s/^....//; $s/\\n$//') | |
# echo "STRIPPED_CHANGELOG=$STRIPPED_CHANGELOG" >> $GITHUB_ENV | |
if [[ -z "$STRIPPED_CHANGELOG" ]]; then | |
echo "Changelog not found for version ${{ env.BUILD_NAME }}." | |
exit 1 | |
fi | |
if [ ${#STRIPPED_CHANGELOG} -gt 500 ]; then | |
echo "Changelog length greater than 500 characters." | |
exit 1 | |
fi | |
echo "$CHANGELOG" > "fastlane/metadata/android/en-US/changelogs/${{ env.BUILD_NUMBER }}.txt" | |
# Insert the changelog entry before the previous version | |
awk -v BUILD_NAME="${{ env.BUILD_NAME }}" -v CHANGELOG="$CHANGELOG" ' | |
/^## \[/{ if (!printed) { print CHANGELOG; printed=1 } } | |
{ print } | |
' $changelog_file > $changelog_file.new && mv $changelog_file.new $changelog_file | |
echo "$CHANGELOG" > changelog.txt | |
echo "$STRIPPED_CHANGELOG" > stripped_changelog.txt | |
echo "$CHANGELOG" | |
echo | |
echo "$STRIPPED_CHANGELOG" | |
- name: Update version in pubspec.yaml | |
run: | | |
perl -i -pe 's/^(version:\s+\d+\.\d+\.\d+\+)(\d+)$/$1.(${{ env.BUILD_NUMBER }})/e' pubspec.yaml | |
- name: Commit changes | |
run: | | |
#git add fastlane/metadata/android | |
#git add pubspec.yaml | |
#git commit -m "Versioning changes for ${{ env.BUILD_NAME }}" | |
#git push | |
build: | |
needs: [prepare_release, bump_submodule] | |
runs-on: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get submodule | |
run: git submodule update --init --recursive | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "zulu" | |
java-version: "17" | |
java-package: jdk | |
- name: Prepare Android signing | |
env: | |
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} | |
KEYSTORE_PASSWORD_ALIAS: ${{ secrets.KEYSTORE_PASSWORD_ALIAS }} | |
run: | | |
# Create the keystore file from the base64 encoded secret | |
echo "$KEYSTORE_BASE64" | base64 --decode > "$RUNNER_TEMP/prod.keystore" | |
cat > "$GITHUB_WORKSPACE/android/key.properties" <<EOF | |
storePassword=$KEYSTORE_PASSWORD | |
keyPassword=$KEYSTORE_PASSWORD_ALIAS | |
keyAlias=$KEYSTORE_ALIAS | |
storeFile=$RUNNER_TEMP/prod.keystore | |
EOF | |
- name: Set up local.properties | |
run: | | |
echo "flutter.sdk=${GITHUB_WORKSPACE}/.flutter" > "$GITHUB_WORKSPACE/android/local.properties" | |
- name: Get packages | |
run: .flutter/bin/flutter pub get | |
- name: Build APK | |
run: .flutter/bin/flutter build apk --release | |
- name: Build AAB | |
run: .flutter/bin/flutter build appbundle --release | |
# - name: Prepare signing | |
# uses: ngeri/prepare-signing@v1.0.2 | |
# with: | |
# appStoreConnectPrivateKey: ${{ secrets.appStoreConnectPrivateKey }} | |
# keyID: ${{ env.keyID }} | |
# issuerID: ${{ env.issuerID }} | |
# keychainName: ${{ secrets.keychainName }} | |
# keychainPassword: ${{ secrets.keychainPassword }} | |
# base64P12File: ${{ secrets.base64P12File }} | |
# p12Password: ${{ secrets.p12Password }} | |
# bundleIdentifier: ${{ env.bundleIdentifier }} | |
# signType: ${{ env.signType }} | |
# | |
# - name: Build IPA | |
# run: .flutter/bin/flutter build ios --release | |
- name: Prepare artifacts | |
run: | | |
mkdir -p artifacts | |
cp build/app/outputs/apk/release/app-release.apk artifacts/graded-${{ needs.prepare_release.outputs.build_name }}.apk | |
cp build/app/outputs/bundle/release/app-release.aab artifacts/graded-${{ needs.prepare_release.outputs.build_name }}.aab | |
cp build/app/outputs/mapping/release/mapping.txt artifacts/mapping.txt | |
cd build/app/intermediates/merged_native_libs/release/out/lib && zip -r -0 $GITHUB_WORKSPACE/artifacts/lib.zip . && cd $GITHUB_WORKSPACE | |
# cp build/ios/ipa/Graded.ipa artifacts/graded-${{ env.BUILD_NAME }}.ipa | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-artifacts | |
path: | | |
- artifacts/graded-${{ needs.prepare_release.outputs.build_name }}.aab | |
- artifacts/graded-${{ needs.prepare_release.outputs.build_name }}.apk | |
- artifacts/mapping.txt | |
- artifacts/lib.zip | |
# - artifacts/graded-${{ env.BUILD_NAME }}.ipa | |
# - /tmp/xcodebuild_logs/*.log | |
publish: | |
needs: [build, test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: release-artifacts | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "artifacts/graded-${{ needs.prepare_release.outputs.build_name }}.apk" | |
bodyFile: "changelog.txt" | |
name: "${{ needs.prepare_release.outputs.build_name }}" | |
tag: "${{ needs.prepare_release.outputs.build_name }}" | |
draft: true | |
commit: master | |
- name: Set track based on input | |
id: set-track | |
run: | | |
if [ "${{ needs.prepare_release.outputs.release_channel }}" == "prod" ]; then | |
echo "TRACK=production" >> $GITHUB_ENV | |
elif [ "${{ needs.prepare_release.outputs.release_channel }}" == "beta" ]; then | |
echo "TRACK=beta" >> $GITHUB_ENV | |
elif [ "${{ needs.prepare_release.outputs.release_channel }}" == "alpha" ]; then | |
echo "TRACK=qa" >> $GITHUB_ENV | |
else | |
echo "TRACK=production" >> $GITHUB_ENV | |
fi | |
- name: Publish to Google Play | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} | |
packageName: com.NightDreamGames.Grade.ly | |
releaseFiles: artifacts/graded-${{ needs.prepare_release.outputs.build_name }}.aab | |
track: ${{ env.TRACK }} | |
whatsNewDirectory: distribution/whatsnew | |
mappingFile: artifacts/mapping.txt | |
debugSymbols: artifacts/lib.zip | |
- name: Publish to App Store | |
run: | | |
# Logic to publish to the App Store |