-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Added GitHub Actions pipeline to release app to GitHub releases
- Loading branch information
1 parent
aecdd1e
commit cc614b5
Showing
10 changed files
with
185 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
name: App release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'release/*' | ||
|
||
jobs: | ||
check: | ||
name: Check application | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Init | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: '3.24.2' | ||
channel: stable | ||
cache: true | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.pub-cache/git | ||
~/.pub-cache/hosted | ||
- name: Check flutter installation | ||
run: flutter --version | ||
# Preparation | ||
- name: Get dependencies | ||
run: dart run melos bootstrap | ||
# Checks | ||
- name: Ensure that code is formatted correctly | ||
run: dart run melos format --set-exit-if-changed --output none $(git ls-files | grep --colour=never -e ".*\.dart") | ||
- name: Analyze code to find critical problems | ||
run: dart run melos exec flutter analyze --no-fatal-infos | ||
# Update generation and locale if needed | ||
- name: Generate with build_runner | ||
run: dart run melos run generate | ||
- name: Update locale | ||
run: dart run melos run l10n | ||
|
||
version_update: | ||
name: Update pubspec version | ||
needs: check | ||
runs-on: ubuntu-latest | ||
outputs: | ||
app_version: ${{ steps.update_version.outputs.app_version }} | ||
app_build_number: ${{ steps.update_version.outputs.app_build_number }} | ||
tag_name: ${{ steps.get_tag.outputs.tag_name }} | ||
branch: ${{ steps.find_branch.outputs.branch }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Get Tag Name | ||
id: get_tag | ||
run: echo "tag_name=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT | ||
- name: Find Branch Containing the Tag Commit | ||
id: find_branch | ||
run: | | ||
BRANCH=$(git branch -r --contains $GITHUB_SHA | grep -v HEAD | head -n 1 | sed 's|origin/||') | ||
echo "branch=$BRANCH" >> $GITHUB_OUTPUT | ||
- name: Checkout Branch | ||
run: git checkout ${{ steps.find_branch.outputs.branch }} | ||
- name: Update Version | ||
run: tools/update_version.sh ${{ steps.get_tag.outputs.tag_name }} >> $GITHUB_OUTPUT | ||
- name: Validate release notes | ||
run: tools/validate_release_notes.sh ${{ steps.update_version.outputs.app_version }} | ||
- name: Commit and Push Changes | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add pubspec.yaml | ||
git commit -m "Bump version to ${{ steps.update_version.outputs.new_version }} [skip ci]" | ||
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }} | ||
git push origin HEAD:${{ steps.find_branch.outputs.branch }} | ||
build: | ||
name: Build android | ||
needs: version_update | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Init | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ needs.version_update.outputs.branch }} | ||
fetch-depth: 0 | ||
- uses: subosito/flutter-action@v2 | ||
with: | ||
flutter-version: '3.24.2' | ||
channel: stable | ||
cache: true | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.pub-cache/git | ||
~/.pub-cache/hosted | ||
- name: Check flutter installation | ||
run: flutter --version | ||
# Preparation | ||
- name: Get dependencies | ||
run: dart run melos bootstrap | ||
- name: Decode and save android keystore | ||
run: | | ||
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > $HOME/keystore.jks | ||
- name: Save key.properties | ||
run: | | ||
touch android/key.properties | ||
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> android/key.properties | ||
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties | ||
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties | ||
echo "storeFile=$HOME/keystore.jks" >> android/key.properties | ||
# Build and upload | ||
- name: Build APK | ||
run: | | ||
flutter build apk --flavor prod --split-per-abi | ||
flutter build apk --flavor prod | ||
TAG=foss tools/android/move-builds.sh | ||
tools/android/check-cert.sh | ||
- name: Upload FOSS APK Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifacts-apk-foss | ||
path: build/releases/android | ||
|
||
release: | ||
name: Release to GitHub actions | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download APKs Directory | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: artifacts-apk-foss | ||
- name: Create GitHub Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ needs.version_update.outputs.tag_name }} | ||
name: v${{ needs.version_update.outputs.app_version }} | ||
bodyFile: release_notes/${{ needs.version_update.outputs.app_version }}/github/RELEASE_NOTES.md | ||
files: 'artifacts-apk-foss/*.apk' | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 0.11.2 | ||
|
||
Test release using GitHub Actions |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/bin/bash | ||
|
||
if [ -f $1 ]; then | ||
cp $1 $2 | ||
else | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
#!/bin/bash | ||
|
||
cat pubspec.yaml | grep "version: " | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
#!/bin/bash | ||
|
||
LINUX_DIR="build/linux/x64/release" | ||
RELEASE_DIR="build/releases/linux" | ||
APP_NAME="not_zero-linux" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
TAG_VERSION="$(echo "$1" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")" | ||
|
||
CURRENT_VERSION=$(grep '^version: ' pubspec.yaml | sed 's/version: //') | ||
CURRENT_BUILD_NUMBER=$(echo "$CURRENT_VERSION" | cut -d'+' -f2) | ||
|
||
if [ -z "$CURRENT_BUILD_NUMBER" ]; then | ||
CURRENT_BUILD_NUMBER=0 | ||
fi | ||
NEW_BUILD_NUMBER=$((CURRENT_BUILD_NUMBER + 1)) | ||
|
||
sed -i "s/version: $CURRENT_VERSION/version: $TAG_VERSION+$NEW_BUILD_NUMBER/" pubspec.yaml | ||
|
||
echo -e "app_version=$TAG_VERSION\n""app_build_number=$NEW_BUILD_NUMBER" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
RELEASE_DIR="release_notes/$1" | ||
RELEASE_FILENAME="RELEASE_NOTES.md" | ||
|
||
if [ ! -f "$RELEASE_DIR/github/$RELEASE_FILENAME" ]; then | ||
echo "Release notes file for GitHub not found" | ||
exit 1 | ||
fi |