Skip to content

Commit

Permalink
Fix CI env
Browse files Browse the repository at this point in the history
  • Loading branch information
FauconSpartiate committed Jan 20, 2024
1 parent 932154f commit 84fbbd3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/bump_submodule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ jobs:
run: |
git submodule update --remote --init
git add .flutter
git commit -m "Upgrade Flutter submodule"
git push
if ! git diff-index --quiet HEAD; then
git commit -m "Upgrade Flutter submodule"
git push origin main
fi
- name: Print Flutter version
run: .flutter/bin/flutter --version
42 changes: 19 additions & 23 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
uses: ./.github/workflows/bump_submodule.yaml

prepare_release:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -36,12 +35,12 @@ jobs:
echo "BUILD_NUMBER=$((${{ github.run_number }} + 246))" >> $GITHUB_ENV
echo "RELEASE_CHANNEL=${{ github.event.inputs.channel }}" >> $GITHUB_ENV
echo "$fullVersion BUILD_NAME: ${BUILD_NAME} BUILD_NUMBER: ${BUILD_NUMBER}"
echo "$fullVersion BUILD_NAME: ${{ env.BUILD_NAME ]}\n BUILD_NUMBER: ${{ env.BUILD_NUMBER }}\n RELEASE_CHANNEL: ${{ env.RELEASE_CHANNEL }}"
- name: Check if version is used
run: |
if [ $(git tag -l "$BUILD_NAME") ]; then
echo "Version $BUILD_NAME already exists"
if [ $(git tag -l "${{ env.BUILD_NAME }}") ]; then
echo "Version ${{ env.BUILD_NAME }} already exists"
exit 1
fi
Expand All @@ -51,16 +50,13 @@ jobs:
# Get the release changelog
changelog_file="CHANGELOG.md"
CHANGELOG=$(sed -n "/\[$BUILD_NAME\]/,/\[.*\] -/p" $changelog_file | sed '$d' | sed '$d' | sed '$s/\\n$//')
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
echo -e "$CHANGELOG"
echo -e "$STRIPPED_CHANGELOG"
if [[ -z "$STRIPPED_CHANGELOG" ]]; then
echo "Changelog not found for version $BUILD_NAME."
echo "Changelog not found for version ${{ env.BUILD_NAME }}."
exit 1
fi
Expand All @@ -69,10 +65,10 @@ jobs:
exit 1
fi
echo "$CHANGELOG" > "fastlane/metadata/android/en-US/changelogs/$BUILD_NUMBER.txt"
echo "$CHANGELOG" > "fastlane/metadata/android/en-US/changelogs/${{ env.BUILD_NUMBER }}.txt"
# Insert the changelog entry before the previous version
awk -v BUILD_NAME="$BUILD_NAME" -v CHANGELOG="$CHANGELOG" '
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
Expand All @@ -86,17 +82,17 @@ jobs:
- name: Update version in pubspec.yaml
run: |
perl -i -pe 's/^(version:\s+\d+\.\d+\.\d+\+)(\d+)$/$1.($BUILD_NUMBER)/e' pubspec.yaml
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 ${BUILD_NAME}"
git commit -m "Versioning changes for ${{ env.BUILD_NAME }}"
git push
build:
needs: [prepare_release, bump_submodule]
needs: [prepare_release, bump_submodule, test]
runs-on: macos-latest
steps:
- name: Get packages
Expand All @@ -113,19 +109,19 @@ jobs:

- name: Prepare artifacts
run: |
cp build/app/outputs/apk/release/app-release.apk artifacts/graded-${BUILD_NAME}.apk
cp build/app/outputs/bundle/release/app-release.aab artifacts/graded-${BUILD_NAME}.aab
cp build/ios/ipa/Graded.ipa artifacts/graded-${BUILD_NAME}.ipa
cp build/app/outputs/apk/release/app-release.apk artifacts/graded-${{ env.BUILD_NAME }}.apk
cp build/app/outputs/bundle/release/app-release.aab artifacts/graded-${{ env.BUILD_NAME }}.aab
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-${BUILD_NAME}.aab
- artifacts/graded-${BUILD_NAME}.apk
- artifacts/graded-${{ env.BUILD_NAME }}.aab
- artifacts/graded-${{ env.BUILD_NAME }}.apk
- build/**/outputs/**/mapping.txt
- artifacts/graded-${BUILD_NAME}.ipa
- artifacts/graded-${{ env.BUILD_NAME }}.ipa
- /tmp/xcodebuild_logs/*.log
publish:
Expand All @@ -135,10 +131,10 @@ jobs:
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/graded-${BUILD_NAME}.apk, artifacts/graded-${BUILD_NAME}.ipa"
artifacts: "artifacts/graded-${{ env.BUILD_NAME }}.apk, artifacts/graded-${{ env.BUILD_NAME }}.ipa"
bodyFile: "changelog.txt"
name: "${BUILD_NAME}"
tag: "${BUILD_NAME}"
name: "${{ env.BUILD_NAME }}"
tag: "${{ env.BUILD_NAME }}"
draft: true
commit: master

Expand Down

0 comments on commit 84fbbd3

Please sign in to comment.