feat(images): add batch select-to-delete and clear unmounted #10
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: Build | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'app/**' | |
| - 'module/**' | |
| - 'gradle/**' | |
| - 'build.gradle.kts' | |
| - 'settings.gradle.kts' | |
| - 'gradle.properties' | |
| - 'scripts/**' | |
| - '.github/workflows/build.yml' | |
| pull_request: | |
| branches: [master] | |
| paths: | |
| - 'app/**' | |
| - 'gradle/**' | |
| - 'build.gradle.kts' | |
| - 'settings.gradle.kts' | |
| - 'gradle.properties' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| profile: [debug, release] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Bump patch version | |
| if: github.event_name == 'push' | |
| run: | | |
| prop="module/module.prop" | |
| ver=$(grep '^version=' "$prop" | cut -d= -f2) | |
| code=$(grep '^versionCode=' "$prop" | cut -d= -f2) | |
| new_code=$((code + 1)) | |
| # Bump patch: v3.1 -> v3.2, v3.1.2 -> v3.1.3 | |
| base="${ver%.*}" | |
| patch="${ver##*.}" | |
| if echo "$patch" | grep -qE '^[0-9]+$'; then | |
| new_ver="${base}.$((patch + 1))" | |
| else | |
| new_ver="${ver}.1" | |
| fi | |
| sed -i "s/^version=.*/version=${new_ver}/" "$prop" | |
| sed -i "s/^versionCode=.*/versionCode=${new_code}/" "$prop" | |
| echo "Bumped: $ver ($code) -> $new_ver ($new_code)" | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| validate-wrappers: false | |
| - name: Decode keystore | |
| if: matrix.profile == 'release' | |
| run: echo "${{ secrets.RELEASE_KEYSTORE }}" | base64 -d > release.jks | |
| - name: Build APK (${{ matrix.profile }}) | |
| run: | | |
| if [ "$PROFILE" = "release" ]; then | |
| ./gradlew assembleRelease | |
| else | |
| ./gradlew assembleDebug | |
| fi | |
| env: | |
| PROFILE: ${{ matrix.profile }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: apk-${{ matrix.profile }} | |
| path: app/build/outputs/apk/${{ matrix.profile }}/app-${{ matrix.profile }}.apk | |
| retention-days: 7 | |
| package: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Read version | |
| id: ver | |
| run: echo "version=$(grep '^version=' module/module.prop | cut -d= -f2)" >> "$GITHUB_OUTPUT" | |
| - name: Package ZIPs | |
| run: | | |
| ver="${{ steps.ver.outputs.version }}" | |
| mkdir -p out/release out/debug | |
| bash scripts/package.sh --apk="artifacts/apk-release/app-release.apk" | |
| mv "out/UsbMassStorage-${ver}.zip" "out/release/" | |
| bash scripts/package.sh --apk="artifacts/apk-debug/app-debug.apk" | |
| mv "out/UsbMassStorage-${ver}.zip" "out/debug/UsbMassStorage-${ver}-debug.zip" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: usbmassstorage-release-zip | |
| path: out/release/*.zip | |
| retention-days: 30 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: usbmassstorage-debug-zip | |
| path: out/debug/*.zip | |
| retention-days: 30 | |
| release: | |
| needs: [build, package] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read version | |
| id: ver | |
| run: echo "version=$(grep '^version=' module/module.prop | cut -d= -f2)" >> "$GITHUB_OUTPUT" | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: usbmassstorage-release-zip | |
| path: zips/release | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: usbmassstorage-debug-zip | |
| path: zips/debug | |
| - name: Extract changelog | |
| run: | | |
| ver="${VER}" | |
| awk "/^## ${ver}/{flag=1; next} /^## v/{if(flag) exit} flag" CHANGELOG.md > /tmp/notes.md | |
| cat /tmp/notes.md | |
| env: | |
| VER: ${{ steps.ver.outputs.version }} | |
| - name: Create release | |
| run: | | |
| gh release delete "$VER" --yes 2>/dev/null || true | |
| gh release create "$VER" \ | |
| --title "$VER" \ | |
| --latest \ | |
| --notes-file /tmp/notes.md \ | |
| zips/release/*.zip \ | |
| zips/debug/*.zip | |
| env: | |
| VER: ${{ steps.ver.outputs.version }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |