VirtualAP CI #41
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 Binaries & Android App | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up QEMU (arm64 + arm emulation) | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: arm64,arm | |
| - name: Build static binaries from source | |
| # Compiles hostapd/iw/dnsmasq (+ busybox) in aarch64 and armhf Alpine | |
| # containers from the externals/ submodules and stages them into | |
| # backend/{aarch64,armhf}. | |
| run: | | |
| chmod +x scripts/build-static.sh scripts/build-in-container.sh | |
| ./scripts/build-static.sh | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| - 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 Artifact | |
| run: | | |
| TAG="${{ github.event.inputs.tag_name || 'test' }}" | |
| DATE=$(date +%Y-%m-%d) | |
| APK_NAME="VirtualAP-${TAG}-${DATE}.apk" | |
| mkdir -p dist | |
| mv Android/app/build/outputs/apk/release/app-release.apk dist/${APK_NAME} | |
| echo "APK_FILE=dist/${APK_NAME}" >> $GITHUB_ENV | |
| - name: Upload APK Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: virtualap-apk | |
| 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 |