This repository has been archived by the owner on Jan 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (115 loc) · 4.29 KB
/
release.yml
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
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=SUPABASE_PROJECT_URL=${{ secrets.SUPABASE_PROJECT_URL }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }}
- name: Rename Android APK
run: mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/ecoparking-release-android-${{ github.ref_name }}.apk
- name: Upload Android artifact
uses: actions/upload-artifact@v4
with:
name: ecoparking-release-android-${{ github.ref_name }}
path: build/app/outputs/flutter-apk/ecoparking-release-android-${{ github.ref_name }}.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=SUPABASE_PROJECT_URL=${{ secrets.SUPABASE_PROJECT_URL }} --dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }} --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: 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: Download Android artifact
uses: actions/download-artifact@v4
with:
name: ecoparking-release-android-${{ github.ref_name }}
- 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: |
ecoparking-release-android-${{ github.ref_name }}.apk