-
Notifications
You must be signed in to change notification settings - Fork 2
147 lines (119 loc) · 4.87 KB
/
release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# .github/workflows/release.yaml
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
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Faucon"
- name: Set environment variables
run: |
fullVersion=$(echo | grep -i -e "version: " pubspec.yaml)
echo "BUILD_NAME=$(echo $fullVersion | cut -d " " -f 2 | cut -d "+" -f 1)" >> $GITHUB_ENV
echo "BUILD_NUMBER=$((${{ github.run_number }} + 246))" >> $GITHUB_ENV
echo "RELEASE_CHANNEL=${{ github.event.inputs.channel }}" >> $GITHUB_ENV
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 "${{ env.BUILD_NAME }}") ]; then
echo "Version ${{ env.BUILD_NAME }} already exists"
exit 1
fi
- name: Update Changelog
run: |
changelog_file="CHANGELOG.md"
# 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, test]
runs-on: macos-latest
steps:
- 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: Build IPA
run: .flutter/bin/flutter build ios --release
- name: Prepare artifacts
run: |
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-${{ env.BUILD_NAME }}.aab
- artifacts/graded-${{ env.BUILD_NAME }}.apk
- build/**/outputs/**/mapping.txt
- artifacts/graded-${{ env.BUILD_NAME }}.ipa
- /tmp/xcodebuild_logs/*.log
publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: "artifacts/graded-${{ env.BUILD_NAME }}.apk, artifacts/graded-${{ env.BUILD_NAME }}.ipa"
bodyFile: "changelog.txt"
name: "${{ env.BUILD_NAME }}"
tag: "${{ env.BUILD_NAME }}"
draft: true
commit: master
- name: Publish to Google Play
run: |
# Logic to publish to Google Play
- name: Publish to App Store
run: |
# Logic to publish to the App Store