VirtualAP CI #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: VirtualAP CI | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| pull_request: | |
| branches: [ "main", "master" ] | |
| workflow_dispatch: | |
| inputs: | |
| create_release: | |
| description: 'Create an Official GitHub Release?' | |
| required: true | |
| type: boolean | |
| default: false | |
| tag_name: | |
| description: 'Tag name (Only used if Release is checked)' | |
| required: false | |
| default: 'test' | |
| jobs: | |
| build: | |
| name: Build Rootfs & Android App | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - name: Grant execute permission for builder script | |
| run: chmod +x rootfs-builder/build_rootfs.sh | |
| - name: Build Rootfs | |
| run: ./rootfs-builder/build_rootfs.sh | |
| - name: Decode Keystore | |
| env: | |
| RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }} | |
| if: ${{ github.event_name != 'pull_request' && env.RELEASE_KEYSTORE != '' }} | |
| run: echo "${{ env.RELEASE_KEYSTORE }}" | base64 -d > virtualap.keystore | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x Android/gradlew | |
| - name: Build Android App with Gradle | |
| env: | |
| KEYSTORE_PASSWORD: ${{ github.event_name != 'pull_request' && secrets.KEYSTORE_PASSWORD || '' }} | |
| KEY_ALIAS: ${{ github.event_name != 'pull_request' && secrets.KEY_ALIAS || '' }} | |
| KEY_PASSWORD: ${{ github.event_name != 'pull_request' && secrets.KEY_PASSWORD || '' }} | |
| run: | | |
| cd Android | |
| ./gradlew assembleRelease \ | |
| -PKEYSTORE_PASSWORD="$KEYSTORE_PASSWORD" \ | |
| -PKEY_ALIAS="$KEY_ALIAS" \ | |
| -PKEY_PASSWORD="$KEY_PASSWORD" | |
| - name: Stage & Rename Artifacts | |
| run: | | |
| TAG="${{ github.event.inputs.tag_name || 'test' }}" | |
| DATE=$(date +%Y-%m-%d) | |
| APK_NAME="VirtualAP-${TAG}-${DATE}.apk" | |
| ROOTFS_NAME=$(basename $(ls out/VirtualAP-rootfs-*.tar.xz)) | |
| mkdir -p dist | |
| mv Android/app/build/outputs/apk/release/app-release.apk dist/${APK_NAME} | |
| cp out/${ROOTFS_NAME} dist/ | |
| echo "APK_FILE=dist/${APK_NAME}" >> $GITHUB_ENV | |
| echo "ROOTFS_FILE=dist/${ROOTFS_NAME}" >> $GITHUB_ENV | |
| - name: Upload Final Artifacts (APK & Rootfs) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: virtualap-artifacts | |
| path: dist/ | |
| release: | |
| name: Create GitHub Release | |
| needs: [build] | |
| if: | | |
| github.event_name == 'workflow_dispatch' && | |
| github.event.inputs.create_release == 'true' && | |
| github.event.inputs.tag_name != '' && | |
| github.event.inputs.tag_name != 'test' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: release-assets | |
| merge-multiple: true | |
| - name: Generate Changelog | |
| id: changelog | |
| run: | | |
| PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| echo "Previous tag: $PREV_TAG" | |
| if [ -z "$PREV_TAG" ]; then | |
| CHANGELOG=$(git log --oneline --pretty=format:"* %s (%h)") | |
| else | |
| CHANGELOG=$(git log ${PREV_TAG}..HEAD --oneline --pretty=format:"* %s (%h)") | |
| fi | |
| { | |
| echo "notes<<EOF" | |
| echo "$CHANGELOG" | |
| echo "EOF" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.event.inputs.tag_name }} | |
| name: VirtualAP ${{ github.event.inputs.tag_name || 'Development Build' }} | |
| target_commitish: ${{ github.sha }} | |
| body: | | |
| ## What's Changed | |
| ${{ steps.changelog.outputs.notes }} | |
| --- | |
| **Automated Release by VirtualAP CI** | |
| files: | | |
| release-assets/*.apk | |
| release-assets/*.tar.xz |