-
-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (170 loc) · 7.32 KB
/
Copy pathalpha.yml
File metadata and controls
200 lines (170 loc) · 7.32 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Alpha Release App
on:
# Every Saturday at 21:00 UTC
# schedule:
# - cron: '0 21 * * 6'
# Manual triggers
workflow_dispatch:
env:
JAVA_VERSION: 21
JAVA_DISTRO: 'temurin'
jobs:
build-app:
runs-on: macos-latest
outputs:
CREATE_RELEASE: ${{ steps.prepare_changelog.outputs.CREATE_RELEASE }}
CHANGELOG: ${{ steps.prepare_changelog.outputs.CHANGELOG }}
COMMIT_COUNT_OUTPUT: ${{ steps.prepare_build.outputs.COMMIT_COUNT_OUTPUT }}
env:
commit_count_diff: 0
PREV_RELEASE_SHA: ''
CURRENT_SHA: ''
COMMIT_COUNT: 0
FGA_VERSION_CODE: 0
FGA_VERSION_NAME: ''
COMMIT_LOGS: ''
TAG_NAME: ''
permissions:
contents: write
discussions: write
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
repository: 'ArthurKun21/FGA-Preview'
token: ${{ secrets.PAT }}
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
path: 'preview'
- name: Get previous release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd preview
OUTPUT=$(gh release list \
--exclude-drafts \
--json tagName \
--limit 100 \
--jq '[.[] | select(.tagName | test("^pre-[0-9]+-alpha$"))] | .[0].tagName')
if [ -n "$OUTPUT" ]; then
echo "TAG_NAME=$OUTPUT" >> $GITHUB_ENV
echo "Latest Tag: $OUTPUT"
else
echo "Failed to get repository information"
exit 1
fi
- name: Prepare build
id: prepare_build
run: |
commit_count=$(git rev-list --count HEAD)
echo "COMMIT_COUNT=$commit_count" >> $GITHUB_ENV
echo "COMMIT_COUNT_OUTPUT=$commit_count" >> $GITHUB_OUTPUT
current_sha=$(git rev-parse --short HEAD)
echo "CURRENT_SHA=$current_sha" >> $GITHUB_ENV
echo "FGA_VERSION_CODE=$commit_count" >>${GITHUB_ENV}
echo "FGA_VERSION_NAME=$current_sha" >>${GITHUB_ENV}
prev_commit_count=$(echo "${{ env.TAG_NAME }}" | sed -E 's/^pre-([0-9]+)(-alpha)?$/\1/')
commit_count_diff=$(($commit_count - $prev_commit_count))
echo "commit_count_diff=$commit_count_diff" >> $GITHUB_ENV
prev_release_sha=$(git rev-parse --short HEAD~$commit_count_diff)
echo "PREV_RELEASE_SHA=$prev_release_sha" >> $GITHUB_ENV
echo "COMMIT_LOGS<<{delimiter}
$(curl -H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
"https://api.github.com/repos/Arthurkun21/fga-preview/compare/$prev_release_sha...$current_sha" \
| jq '[.commits[]|{message:(.commit.message | split("\n")), username:.author.login}]' \
| jq -r '.[]|"- \(.message | first) (@\(.username))"')
{delimiter}" >> $GITHUB_ENV
- name: Prepare changelog
id: prepare_changelog
if: ${{ env.commit_count_diff > 0 }}
run: |
# Get the current date
CURRENT_DATE=$(date +"%Y-%m-%d")
CHANGELOG="# ${COMMIT_COUNT}\n\n$CURRENT_DATE\n\n${COMMIT_LOGS}"
echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT
echo -e "$CHANGELOG" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "CREATE_RELEASE=true" >> $GITHUB_OUTPUT
- name: Validate Gradle Wrapper
if: ${{ env.commit_count_diff > 0 }}
uses: gradle/actions/wrapper-validation@v6.3.0
- name: Set up JDK 21
if: ${{ env.commit_count_diff > 0 }}
uses: actions/setup-java@v6
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
- name: Set up gradle
if: ${{ env.commit_count_diff > 0 }}
uses: gradle/actions/setup-gradle@v6.3.0
- name: Build Android Package
if: ${{ env.commit_count_diff > 0 }}
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew assembleCi --parallel --no-daemon
- name: Clean up build artifacts
if: ${{ env.commit_count_diff > 0 }}
run: |
cp app/build/outputs/apk/ci/app-universal-ci.apk fga-preview-alpha-build-${{ env.COMMIT_COUNT }}.apk
cp app/build/outputs/apk/ci/app-arm64-v8a-ci.apk fga-preview-alpha-build-arm64-v8a-${{ env.COMMIT_COUNT }}.apk
cp app/build/outputs/apk/ci/app-armeabi-v7a-ci.apk fga-preview-alpha-build-armeabi-v7a-${{ env.COMMIT_COUNT }}.apk
cp app/build/outputs/apk/ci/app-x86_64-ci.apk fga-preview-alpha-build-x86_64-${{ env.COMMIT_COUNT }}.apk
cp app/build/outputs/apk/ci/app-x86-ci.apk fga-preview-alpha-build-x86-${{ env.COMMIT_COUNT }}.apk
- name: Create release on forked repo
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
if: ${{ env.commit_count_diff > 0 }}
with:
tag_name: pre-${{ env.COMMIT_COUNT }}-alpha
name: FGA Preview - Alpha ${{ env.COMMIT_COUNT }}
repository: ArthurKun21/FGA
body: |
# Alpha-${{ env.COMMIT_COUNT }}
Check out our documentation website: https://arthurkun21.github.io/FGA-Preview-Build/
## Commits
${{ env.COMMIT_LOGS }}
> [!IMPORTANT]
>
> This is an alpha build and may contain bugs.
> [!TIP]
>
> If you are unsure which version to download then go with `fga-preview-alpha-build-${{ env.COMMIT_COUNT }}.apk`
files: |
fga-preview-alpha-build-${{ env.COMMIT_COUNT }}.apk
fga-preview-alpha-build-arm64-v8a-${{ env.COMMIT_COUNT }}.apk
fga-preview-alpha-build-armeabi-v7a-${{ env.COMMIT_COUNT }}.apk
fga-preview-alpha-build-x86_64-${{ env.COMMIT_COUNT }}.apk
fga-preview-alpha-build-x86-${{ env.COMMIT_COUNT }}.apk
token: ${{ secrets.RELEASE_ON_ANOTHER_REPO }}
- name: Create release
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2
if: ${{ env.commit_count_diff > 0 }}
with:
tag_name: pre-${{ env.COMMIT_COUNT }}-alpha
name: FGA Preview - Alpha ${{ env.COMMIT_COUNT }}
body: |
# Alpha-${{ env.COMMIT_COUNT }}
Check out our documentation website: https://arthurkun21.github.io/FGA-Preview-Build/
## Commits
${{ env.COMMIT_LOGS }}
> [!IMPORTANT]
>
> This is an alpha build and may contain bugs.
> [!TIP]
>
> If you are unsure which version to download then go with `fga-preview-alpha-build-${{ env.COMMIT_COUNT }}.apk`
files: |
fga-preview-alpha-build-${{ env.COMMIT_COUNT }}.apk
fga-preview-alpha-build-arm64-v8a-${{ env.COMMIT_COUNT }}.apk
fga-preview-alpha-build-armeabi-v7a-${{ env.COMMIT_COUNT }}.apk
fga-preview-alpha-build-x86_64-${{ env.COMMIT_COUNT }}.apk
fga-preview-alpha-build-x86-${{ env.COMMIT_COUNT }}.apk
prerelease: true
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}