Skip to content

Commit 16a9b41

Browse files
authored
Merge pull request #124 from MostroP2P/remove-unused-dependencies
Remove unused dependencies from pubspec.yaml and modified github actions to build only on version change
2 parents eba908e + 710d657 commit 16a9b41

File tree

3 files changed

+63
-20
lines changed

3 files changed

+63
-20
lines changed

.github/workflows/main.yml

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
push:
77
branches:
88
- main
9+
workflow_dispatch:
910

1011
jobs:
1112
build:
@@ -15,20 +16,70 @@ jobs:
1516
steps:
1617
- name: Checkout Repository
1718
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 2
21+
fetch-tags: true
22+
23+
- name: Check if version changed
24+
id: check_version_change
25+
run: |
26+
# Get current version
27+
CURRENT_VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
28+
echo "Current version: $CURRENT_VERSION"
29+
30+
# Get previous version (from previous commit) with safeguard for shallow history
31+
if git rev-parse --quiet --verify HEAD~1 >/dev/null; then
32+
git checkout HEAD~1 pubspec.yaml
33+
PREVIOUS_VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
34+
git checkout -q HEAD pubspec.yaml
35+
echo "Previous version: $PREVIOUS_VERSION"
36+
else
37+
echo "No previous commit - assuming version unchanged"
38+
PREVIOUS_VERSION=$CURRENT_VERSION
39+
fi
40+
41+
# Compare versions and set output
42+
if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then
43+
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION"
44+
echo "VERSION_CHANGED=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "Version unchanged: $CURRENT_VERSION"
47+
echo "VERSION_CHANGED=false" >> $GITHUB_OUTPUT
48+
fi
49+
50+
# Always store the current version for later steps
51+
echo "VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
52+
53+
- name: Check if build should continue
54+
id: should_build
55+
run: |
56+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
57+
echo "Building because workflow was manually triggered"
58+
echo "SHOULD_BUILD=true" >> $GITHUB_OUTPUT
59+
elif [[ "${{ steps.check_version_change.outputs.VERSION_CHANGED }}" == "true" ]]; then
60+
echo "Building because version changed"
61+
echo "SHOULD_BUILD=true" >> $GITHUB_OUTPUT
62+
else
63+
echo "Skipping build because version did not change"
64+
echo "SHOULD_BUILD=false" >> $GITHUB_OUTPUT
65+
fi
1866
1967
- name: Set Up Java
68+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
2069
uses: actions/setup-java@v3.12.0
2170
with:
2271
distribution: 'oracle'
2372
java-version: '17'
2473

2574
- name: Set Up Flutter
75+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
2676
uses: subosito/flutter-action@v2
2777
with:
2878
flutter-version: '3.32.2'
2979
channel: 'stable'
3080

3181
- name: Cache Dart & Pub artifacts
82+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
3283
uses: actions/cache@v3
3384
with:
3485
path: |
@@ -37,32 +88,40 @@ jobs:
3788
key: ${{ runner.os }}-dart-${{ hashFiles('**/pubspec.yaml') }}
3889

3990
- name: Install Dependencies
91+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
4092
run: flutter pub get
4193

4294
- name: Generate localization and other required files
95+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
4396
run: dart run build_runner build -d
4497

4598
- name: Extract version from pubspec.yaml
99+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
46100
id: extract_version
47101
run: |
48102
version=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')
49103
echo "VERSION=$version" >> $GITHUB_ENV
50104
51105
- name: Build APK
106+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
52107
run: flutter build apk --release --dart-define=APP_VERSION=${{ env.VERSION }} --dart-define=GIT_COMMIT=${{ github.sha }}
53108

54109
- name: Build appBundle
110+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
55111
run: flutter build appbundle --release --dart-define=APP_VERSION=${{ env.VERSION }} --dart-define=GIT_COMMIT=${{ github.sha }}
56112

57113
- name: Build IPA
114+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
58115
run: flutter build ipa --no-codesign --dart-define=APP_VERSION=${{ env.VERSION }} --dart-define=GIT_COMMIT=${{ github.sha }}
59116

60117
- name: Compress Archives and IPAs
118+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
61119
run: |
62120
cd build
63121
tar -czf ios_build.tar.gz ios
64122
65123
- name: Upload Artifacts
124+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
66125
uses: actions/upload-artifact@v4
67126
with:
68127
name: Releases
@@ -72,6 +131,7 @@ jobs:
72131
build/ios_build.tar.gz
73132
74133
- name: Check if Tag Exists
134+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
75135
id: check_tag
76136
run: |
77137
if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then
@@ -81,13 +141,14 @@ jobs:
81141
fi
82142
83143
- name: Modify Tag
84-
if: ${{ env.TAG_EXISTS }} == 'true'
144+
if: steps.should_build.outputs.SHOULD_BUILD == 'true' && env.TAG_EXISTS == 'true'
85145
id: modify_tag
86146
run: |
87147
new_version="${{ env.VERSION }}-alpha-${{ github.run_number }}"
88148
echo "VERSION=$new_version" >> $GITHUB_ENV
89-
149+
90150
- name: Create Release
151+
if: steps.should_build.outputs.SHOULD_BUILD == 'true'
91152
uses: ncipollo/release-action@v1
92153
with:
93154
artifacts: "build/app/outputs/flutter-apk/app-release.apk,build/app/outputs/bundle/release/app-release.aab,build/ios_build.tar.gz"

pubspec.lock

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,6 @@ packages:
9797
url: "https://pub.dev"
9898
source: hosted
9999
version: "1.0.6"
100-
bitcoin_icons:
101-
dependency: "direct main"
102-
description:
103-
name: bitcoin_icons
104-
sha256: "6ee9e69d78683035c089ebc91c3c9de95f7694d7bdcfa7edbbd51d832876f9b3"
105-
url: "https://pub.dev"
106-
source: hosted
107-
version: "0.0.4"
108100
boolean_selector:
109101
dependency: transitive
110102
description:
@@ -812,14 +804,6 @@ packages:
812804
url: "https://pub.dev"
813805
source: hosted
814806
version: "3.0.1"
815-
line_icons:
816-
dependency: "direct main"
817-
description:
818-
name: line_icons
819-
sha256: "249d781d922f5437ac763d9c8f5a02cf5b499a6dc3f85e4b92e074cff0a932ab"
820-
url: "https://pub.dev"
821-
source: hosted
822-
version: "2.0.3"
823807
lints:
824808
dependency: transitive
825809
description:

pubspec.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ dependencies:
4545
google_fonts: ^6.2.1
4646
timeago: ^3.7.0
4747
flutter_riverpod: ^2.6.1
48-
bitcoin_icons: ^0.0.4
4948
collection: ^1.18.0
5049
elliptic: ^0.3.11
5150
intl: ^0.20.2
@@ -61,7 +60,6 @@ dependencies:
6160
sembast: ^3.8.2
6261
sembast_web: ^2.4.1
6362
circular_countdown: ^2.1.0
64-
line_icons: ^2.0.3
6563
introduction_screen: ^3.1.17
6664
riverpod_annotation: ^2.6.1
6765
lucide_icons: ^0.257.0

0 commit comments

Comments
 (0)