action version updated #4
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: Build Release - APK and AAB | |
on: | |
push: | |
branches: [ master ] | |
env: | |
MAJOR_VERSION: 2 | |
MINOR_VERSION: 0 | |
jobs: | |
build: | |
name: Build APK and AAB | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.24.3' | |
- name: Get dependencies | |
run: flutter pub get | |
- name: Analyze code | |
run: flutter analyze | |
- name: Build APK | |
run: flutter build apk --release | |
- name: Build AAB | |
run: flutter build appbundle --release | |
- name: Get latest tag | |
id: get_tag | |
run: | | |
git fetch --tags | |
TAG=$(git describe --tags `git rev-list --tags --max-count=1`) | |
echo "Latest tag: $TAG" | |
echo "::set-output name=tag::$TAG" | |
- name: Calculate new tag | |
id: new_tag | |
run: | | |
LATEST_TAG=${{ steps.get_tag.outputs.tag }} | |
if [ -z "$LATEST_TAG" ]; then | |
NEW_TAG="${{env.MAJOR_VERSION}}.${{env.MINOR_VERSION}}.1" | |
else | |
BASE_TAG="${LATEST_TAG%.*}" | |
PATCH_VERSION="${LATEST_TAG##*.}" | |
NEW_PATCH_VERSION=$((PATCH_VERSION+2)) # Increment by 2 | |
NEW_TAG="${BASE_TAG}.${NEW_PATCH_VERSION}" | |
fi | |
echo "New tag: $NEW_TAG" | |
echo "::set-output name=new_tag::$NEW_TAG" | |
- name: Tag version | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git tag ${{ steps.new_tag.outputs.new_tag }} | |
git push origin ${{ steps.new_tag.outputs.new_tag }} | |
- name: Push tag and release | |
uses: ncipollo/release-action@v1 | |
with: | |
token: ${{ secrets.TOKEN }} | |
artifacts: "build/app/outputs/apk/release/*.apk, build/app/outputs/bundle/release/*.aab" | |
tag: ${{ steps.new_tag.outputs.new_tag }} | |
prerelease: false | |
- name: Upload APK artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-apk | |
path: build/app/outputs/apk/release/*.apk | |
- name: Upload AAB artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-aab | |
path: build/app/outputs/bundle/release/*.aab |