Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,27 @@ jobs:
git diff --staged --quiet || git commit -m "ci: Update README badges [skip ci]"
git push

check-skip:
name: Check Skip Conditions
runs-on: ubuntu-latest
outputs:
skip_release: ${{ steps.check.outputs.skip_release }}
steps:
- name: Check if chore commit
id: check
run: |
COMMIT_MSG="${{ github.event.head_commit.message }}"
FIRST_LINE=$(echo "$COMMIT_MSG" | head -n 1)
if [[ "$FIRST_LINE" == chore:* ]]; then
echo "skip_release=true" >> "$GITHUB_OUTPUT"
else
echo "skip_release=false" >> "$GITHUB_OUTPUT"
fi

publish:
name: Publish to Maven Central
needs: test-and-coverage
if: ${{ !startsWith(github.event.head_commit.message, 'chore:') }}
needs: [test-and-coverage, check-skip]
if: needs.check-skip.outputs.skip_release != 'true'
runs-on: macos-latest
environment: default
steps:
Expand Down Expand Up @@ -185,28 +202,44 @@ jobs:

github-release:
name: GitHub Release
needs: [publish, update-badges]
needs: [test-and-coverage, update-badges]
if: always() && needs.test-and-coverage.result == 'success'
continue-on-error: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17

- uses: gradle/actions/setup-gradle@v4

- name: Build APK
run: ./gradlew :androidApp:assembleRelease

- name: Read version from gradle.properties
id: version
run: |
VERSION=$(grep 'jsoncmp.version=' gradle.properties | cut -d= -f2)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Create GitHub Release
- name: Create GitHub Release with APK
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=${{ steps.version.outputs.version }}
TAG="v${VERSION}"
APK_PATH=$(find androidApp/build/outputs/apk/release -name '*.apk' | head -1)
APK_NAME="JsonCMP-Sample-${VERSION}.apk"
cp "$APK_PATH" "$APK_NAME"

if gh release view "$TAG" > /dev/null 2>&1; then
echo "Release $TAG already exists, skipping."
else
gh release create "$TAG" \
"$APK_NAME" \
--title "$TAG" \
--generate-notes \
--target main
Expand Down
Loading