Skip to content

Commit

Permalink
EF-09: Config release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
hieutbui committed Oct 20, 2024
1 parent a6699f4 commit f1da9c4
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
on:
push:
tags:
- 'v*.*.*'

env:
Flutter_Version: 3.24.2

name: Release

jobs:
build-android:
name: Build Android version
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.Flutter_Version }}
channel: 'stable'
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}"

- name: Create .env file
run: |
echo "" > .env
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Build Android version
run: |
flutter clean
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build apk --release --dart-define=MAPBOX_URL_TEMPLATE=${{ secrets.MAPBOX_URL_TEMPLATE }}
- name: Upload Android artifact
uses: actions/upload-artifact@v4
with:
name: ecoparking-release-android-${{ github.ref_name }}
path: build/app/outputs/flutter-apk/app-release.apk

build-web:
name: Build Web version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.Flutter_Version }}
channel: 'stable'
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}"

- name: Create .env file
run: |
echo "" > .env
- name: Build Web version
env:
FOLDER: '/release/${{ github.ref_name }}/'
run: |
flutter config --enable-web
flutter clean
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build web --release --dart-define=MAPBOX_URL_TEMPLATE=${{ secrets.MAPBOX_URL_TEMPLATE }} --base-href="/${GITHUB_REPOSITORY##*/}/$FOLDER/"
- name: Configure environments
id: configure
env:
FOLDER: '/release/${{ github.ref_name }}/'
run: |
echo "URL=https://$GITHUB_REPOSITORY_OWNER.github.io/${GITHUB_REPOSITORY##*/}/$FOLDER" >> $GITHUB_OUTPUT
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/web
keep_files: true
destination_dir: release/${{ github.ref_name }}

- name: Upload Web artifact
uses: actions/upload-artifact@v4
with:
name: ecoparking-release-web-${{ github.ref_name }}
path: build/web

- name: Remove .env file
run: |
rm .env
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-android, build-web]
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set Repository Name
id: set_repo_name
run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV

- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_NAME: ${{ env.REPO_NAME }}
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref_name }}
body: |
See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md) for full changelogs.
Web version is available at: https://${{ github.repository_owner }}.github.io/${{env.REPO_NAME}}/release/${{ github.ref_name }}
files: |
artifacts/ecoparking-release-android-${{ github.ref_name }}
artifacts/ecoparking-release-web-${{ github.ref_name }}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## v0.0.1 - 20/10/2024
### Added
- Map migration
- Implement UI for book tickets flow
- Config workflow for PR-preview and Release

0 comments on commit f1da9c4

Please sign in to comment.