-
Notifications
You must be signed in to change notification settings - Fork 5
180 lines (162 loc) · 6.11 KB
/
release.yml
File metadata and controls
180 lines (162 loc) · 6.11 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Build & Release
# Trigger on push to master branch or with a tag
on:
push:
branches:
- '**'
tags:
- 'v*'
# If previous workflow is still running, we push again, we will cancel the previous workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
Build:
strategy:
fail-fast: false
matrix:
include:
- target: Android
os: ubuntu-latest
artifact_name: release-Android
artifact_path: build/app/outputs/flutter-apk/*.apk
- target: Windows
os: windows-latest
artifact_name: release-Windows
artifact_path: |
build/windows/outputs/*.zip
build/windows/outputs/*.exe
outputs:
version: ${{ steps.get_version.outputs.version }}
date: ${{ steps.get_version.outputs.date}}
runs-on: ${{ matrix.os }}
env:
FLUTTER_VERSION: 3.27.3
steps:
# Checkout branch
- name: Checkout
uses: actions/checkout@v4
# Add Android keystore
- name: Setup Android keystore
if: matrix.target == 'Android'
run: |
echo "${{ secrets.ENCODED_KEYSTORE }}" | base64 -di > android/app/cloudchewie.jks
echo "${{ secrets.KEY_PROPERTIES }}" > android/key.properties
# Setup Flutter
- name: Setup Flutter
uses: subosito/flutter-action@v2.21.0
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
# Setup JDK
- name: Setup JDK 17 (Android)
if: matrix.target == 'Android'
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
cache: gradle
# Flutter Pub Get
- name: Flutter Pub Get
run: |
git config --global core.longpaths true
flutter doctor -v
flutter pub get
dart run intl_utils:generate
# Get app version
- name: Get app version
id: get_version
shell: bash
run: |
echo "version=$(head -n 2 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2 | cut -d '+' -f 1)" >> $GITHUB_OUTPUT
echo "date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
# Build Android .apk
- name: Build Android
if: matrix.target == 'Android'
run: |
flutter build apk --release
flutter build apk --release --split-per-abi
cd build/app/outputs/flutter-apk
mv app-release.apk Loftify-${{ steps.get_version.outputs.version }}-android-universal.apk
mv app-arm64-v8a-release.apk Loftify-${{ steps.get_version.outputs.version }}-android-arm64-v8a.apk
mv app-armeabi-v7a-release.apk Loftify-${{ steps.get_version.outputs.version }}-android-armeabi-v7a.apk
mv app-x86_64-release.apk Loftify-${{ steps.get_version.outputs.version }}-android-x86_64.apk
# Build Windows .zip
- name: Build Windows
if: matrix.target == 'Windows'
run: |
flutter build windows --release
$DestDir = "build\windows\outputs\Loftify-${{ steps.get_version.outputs.version }}-windows-x86_64"
$SrcDir = "build\windows\x64\runner\Release"
$dllDir = "tools\windows_dll"
Copy-Item -Filter *.dll -Path $dllDir\* -Destination $SrcDir -Force
New-Item -Path $DestDir -ItemType Directory
Copy-Item $SrcDir\* -Recurse $DestDir
Compress-Archive $DestDir build\windows\outputs\Loftify-${{ steps.get_version.outputs.version }}-windows-x86_64.zip
(Get-Content tools/windows_tools/Loftify.iss) -replace '#define MyAppVersion ".*"', '#define MyAppVersion "${{ steps.get_version.outputs.version }}"' | Set-Content tools/windows_tools/Loftify.iss
# Build Windows .exe
- name: Build Windows Installer
if: matrix.target == 'Windows'
uses: Minionguyjpro/Inno-Setup-Action@v1.2.6
with:
path: tools/windows_tools/Loftify.iss
# Upload Artifacts
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_path }}
Publish:
if: startsWith(github.ref, 'refs/tags/')
name: Publish
needs: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get app version
id: get_version
shell: bash
run: |
echo "version=$(head -n 2 pubspec.yaml | tail -n 1 | cut -d ' ' -f 2 | cut -d '+' -f 1)" >> $GITHUB_OUTPUT
- name: Make tmp dir
run: mkdir /tmp/artifacts
- name: Download all Artifacts
uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
- name: List and move all Artifacts
run: |
mkdir -p /tmp/artifacts/final
mv /tmp/artifacts/release-Android/*.apk /tmp/artifacts/final/
mv /tmp/artifacts/release-Windows/*.zip /tmp/artifacts/final/
mv /tmp/artifacts/release-Windows/*.exe /tmp/artifacts/final/
cd /tmp/artifacts/final
for file in *; do
if [ -f "$file" ]; then
sha1sum "$file" | awk '{ print $1 }' > "$file.sha1"
fi
done
ls -R /tmp/artifacts/final
- name: Upload to S3
uses: Robert-Stackflow/upload-s3-action@master
with:
endpoint: ${{ secrets.AWS_ENDPOINT }}
aws_key_id: ${{ secrets.AWS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
aws_bucket: ${{ secrets.AWS_BUCKET }}
source_dir: /tmp/artifacts/final
destination_dir: Loftify/${{ steps.get_version.outputs.version }}
- name: Upload to release
uses: Robert-Stackflow/release-action@master
with:
tag: ${{ github.ref_name }}
allowUpdates: true
generateReleaseNotes: true
artifacts: /tmp/artifacts/final/*
artifactErrorsFailBuild: true
replacesArtifacts: true
makeLatest: true
draft: true
updateOnlyUnreleased: true