Skip to content

Commit 22a2344

Browse files
authored
chore: Attach sample apk during main merge (#6)
1 parent 22b0f98 commit 22a2344

1 file changed

Lines changed: 37 additions & 4 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,27 @@ jobs:
127127
git diff --staged --quiet || git commit -m "ci: Update README badges [skip ci]"
128128
git push
129129
130+
check-skip:
131+
name: Check Skip Conditions
132+
runs-on: ubuntu-latest
133+
outputs:
134+
skip_release: ${{ steps.check.outputs.skip_release }}
135+
steps:
136+
- name: Check if chore commit
137+
id: check
138+
run: |
139+
COMMIT_MSG="${{ github.event.head_commit.message }}"
140+
FIRST_LINE=$(echo "$COMMIT_MSG" | head -n 1)
141+
if [[ "$FIRST_LINE" == chore:* ]]; then
142+
echo "skip_release=true" >> "$GITHUB_OUTPUT"
143+
else
144+
echo "skip_release=false" >> "$GITHUB_OUTPUT"
145+
fi
146+
130147
publish:
131148
name: Publish to Maven Central
132-
needs: test-and-coverage
133-
if: ${{ !startsWith(github.event.head_commit.message, 'chore:') }}
149+
needs: [test-and-coverage, check-skip]
150+
if: needs.check-skip.outputs.skip_release != 'true'
134151
runs-on: macos-latest
135152
environment: default
136153
steps:
@@ -185,28 +202,44 @@ jobs:
185202

186203
github-release:
187204
name: GitHub Release
188-
needs: [publish, update-badges]
205+
needs: [test-and-coverage, update-badges]
206+
if: always() && needs.test-and-coverage.result == 'success'
207+
continue-on-error: true
189208
runs-on: ubuntu-latest
190209
steps:
191210
- uses: actions/checkout@v4
192211

212+
- uses: actions/setup-java@v4
213+
with:
214+
distribution: zulu
215+
java-version: 17
216+
217+
- uses: gradle/actions/setup-gradle@v4
218+
219+
- name: Build APK
220+
run: ./gradlew :androidApp:assembleRelease
221+
193222
- name: Read version from gradle.properties
194223
id: version
195224
run: |
196225
VERSION=$(grep 'jsoncmp.version=' gradle.properties | cut -d= -f2)
197226
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
198227
199-
- name: Create GitHub Release
228+
- name: Create GitHub Release with APK
200229
env:
201230
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
202231
run: |
203232
VERSION=${{ steps.version.outputs.version }}
204233
TAG="v${VERSION}"
234+
APK_PATH=$(find androidApp/build/outputs/apk/release -name '*.apk' | head -1)
235+
APK_NAME="JsonCMP-Sample-${VERSION}.apk"
236+
cp "$APK_PATH" "$APK_NAME"
205237
206238
if gh release view "$TAG" > /dev/null 2>&1; then
207239
echo "Release $TAG already exists, skipping."
208240
else
209241
gh release create "$TAG" \
242+
"$APK_NAME" \
210243
--title "$TAG" \
211244
--generate-notes \
212245
--target main

0 commit comments

Comments
 (0)