Update main.yml #17
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" | |
on: | |
pull_request: | |
branches: [main] | |
push: | |
branches: [main] | |
jobs: | |
build: | |
name: Build & Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set Up Java | |
uses: actions/setup-java@v3.12.0 | |
with: | |
distribution: 'oracle' | |
java-version: '17' | |
- name: Set Up Flutter | |
uses: subosito/flutter-action@v2 | |
with: | |
flutter-version: '3.22.2' | |
channel: 'stable' | |
- name: Cache Flutter Dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ runner.tool_cache }}/pub | |
key: ${{ runner.os }}-flutter-pub-${{ hashFiles('**/jeketi-app/pubspec.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-flutter-pub- | |
- name: Install Dependencies | |
run: flutter pub get | |
working-directory: jeketi-app # Adjust this to your actual project root | |
- name: Build APK | |
run: flutter build apk --release | |
working-directory: jeketi-app # Adjust this to your actual project root | |
- name: Extract version from pubspec.yaml | |
id: extract_version | |
run: | | |
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r') | |
echo "VERSION=$version" >> $GITHUB_ENV | |
working-directory: jeketi-app # Adjust this to your actual project root | |
- name: Generate Unique Tag | |
id: generate_tag | |
run: | | |
base_version="${{ env.VERSION }}" | |
unique_tag="${base_version}-build-${{ github.run_number }}" | |
echo "UNIQUE_TAG=$unique_tag" >> $GITHUB_ENV | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "jeketi-app/build/app/outputs/flutter-apk/app-release.apk" | |
tag: v${{ env.UNIQUE_TAG }} | |
token: ${{ secrets.TOKEN }} | |
name: "Release v${{ env.UNIQUE_TAG }}" | |
body: "Rilis otomatis dari GitHub Actions" | |
- name: Configure Git | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Push Changes | |
run: | | |
git add . | |
git commit -m "Release v${{ env.UNIQUE_TAG }}" | |
git push https://${{ secrets.TOKEN }}@github.com/fskhri/jeketi-app.git | |
continue-on-error: true |