-
-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (170 loc) · 6.97 KB
/
test-release.yaml
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Compile and release test build
on:
push:
branches:
- main
pull_request:
jobs:
prepare:
runs-on: ubuntu-latest
if: startsWith(github.head_ref, 'release-v')
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from pubspec.yaml
run: |
VERSION_FULL=$(grep '^version:' pubspec.yaml | sed 's/version: //')
VERSION_NAME=$(echo $VERSION_FULL | cut -d '+' -f 1)
VERSION_NUMBER=$(echo $VERSION_FULL | cut -d '+' -f 2)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_ENV
echo "Version Name: $VERSION_NAME"
echo "Version Number: $VERSION_NUMBER"
- name: Generate changelog
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
args: --tag $VERSION_NAME a547cf240dd36443a9a00eb38c0ecc6e8acfd963..
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
- name: Commit Changelog
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git checkout ${{ github.head_ref }}
git add CHANGELOG.md
git commit -m "Update CHANGELOG for version $VERSION_NAME"
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.head_ref }}
- name: Update PR Title
if: github.event_name == 'pull_request'
run: |
PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
NEW_TITLE="chore(release): prepare for v${VERSION_NAME}"
curl -X PATCH -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER \
-d "{\"title\":\"$NEW_TITLE\"}"
get-version:
name: Extract Version from pubspec.yaml
runs-on: ubuntu-latest
needs: prepare
if: startsWith(github.ref, 'refs/heads/release-v')
outputs:
VERSION_NAME: ${{ steps.extract_version.outputs.VERSION_NAME }}
VERSION_NUMBER: ${{ steps.extract_version.outputs.VERSION_NUMBER }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION_FULL=$(grep '^version:' pubspec.yaml | sed 's/version: //')
VERSION_NAME=$(echo $VERSION_FULL | cut -d '+' -f 1)
VERSION_NUMBER=$(echo $VERSION_FULL | cut -d '+' -f 2)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_ENV
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_OUTPUT
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_OUTPUT
echo "Extracted Version Name: $VERSION_NAME"
echo "Extracted Version Number: $VERSION_NUMBER"
# build-android:
# name: Build test Android .apk and .aab
# runs-on: ubuntu-latest
# needs: get-version
# env:
# ANDROID_AAB_RELEASE_PATH: build/app/outputs/bundle/release
# ANDROID_APK_RELEASE_PATH: build/app/outputs/apk/release
# VERSION_NAME: ${{ needs.get-version.outputs.VERSION_NAME }}
# VERSION_NUMBER: ${{ needs.get-version.outputs.VERSION_NUMBER }}
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Decode android/app/keystore.jks
# run: echo "${{ secrets.KEYSTORE_JKS }}" | base64 --decode > android/app/keystore.jks
# - name: Decode android/key.properties
# run: echo "${{ secrets.KEY_PROPERTIES }}" | base64 --decode > android/key.properties
# # Enable: take screenshot and output debug log
# - name: Decode .env
# run: echo "${{ secrets.TEST_ENV }}" | base64 --decode > .env
# - name: Setup Java 17
# uses: actions/setup-java@v4
# with:
# distribution: temurin
# java-version: 17
# - name: Setup Flutter
# uses: subosito/flutter-action@v2
# with:
# channel: stable
# cache: true
# - run: flutter clean
# - run: flutter pub get
# - name: Build apk
# run: flutter build apk --release
# - name: Build aab
# run: flutter build appbundle --release
# - name: Rename apk
# run: mv $ANDROID_APK_RELEASE_PATH/app-release.apk PiHoleClient_${{ env.VERSION_NAME }}_Android.apk
# - name: Rename aab
# run: mv $ANDROID_AAB_RELEASE_PATH/app-release.aab PiHoleClient_${{ env.VERSION_NAME }}_Android.aab
# - name: Upload artifact
# uses: actions/upload-artifact@v4
# with:
# name: android
# path: |
# PiHoleClient_${{ env.VERSION_NAME }}_Android.apk
# PiHoleClient_${{ env.VERSION_NAME }}_Android.aab
# test-build-google-play:
# name: Release Android test build to the Google Play Store
# runs-on: ubuntu-latest
# needs: [get-version, build-android]
# permissions:
# contents: read
# id-token: write
# env:
# VERSION_NAME: ${{ needs.get-version.outputs.VERSION_NAME }}
# VERSION_NUMBER: ${{ needs.get-version.outputs.VERSION_NUMBER }}
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Download Android artifacts
# uses: actions/download-artifact@v4
# with:
# name: android
# - id: auth
# uses: google-github-actions/auth@v2
# with:
# workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY }}
# service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
# - name: Release app to Google Play
# uses: r0adkll/upload-google-play@v1
# with:
# serviceAccountJson: ${{ steps.auth.outputs.credentials_file_path }}
# packageName: io.github.tsutsu3.pi_hole_client
# releaseFiles: PiHoleClient_${{ env.VERSION_NAME }}_Android.aab
# track: alpha # Available tracks are: production,beta,alpha,internal,test
# status: draft
# releaseName: ${{ env.VERSION_NAME }}
bump-version:
name: Bump version in pubspec.yaml
runs-on: ubuntu-latest
needs: get-version
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- run: flutter clean
- run: flutter pub get
- name: Bump version in pubspec.yaml
run: dart run pub_version_plus:main build
- name: Commit version bump
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add pubspec.yaml
git commit -m "Bump build version"
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git ${{ github.head_ref }}