Bump version to 2.7.4 #25
Workflow file for this run
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: Release (APK + Backend) | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: release-${{ github.ref }} | |
| cancel-in-progress: false | |
| env: | |
| JAVA_VERSION: "17" | |
| FLUTTER_VERSION: "3.32.1" | |
| FLUTTER_PROJECT: "flutter" | |
| RUST_BACKEND_DIR: "backend" | |
| RUST_TOOLCHAIN: "stable" | |
| jobs: | |
| android: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: ${{ env.JAVA_VERSION }} | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| cache: true | |
| - uses: android-actions/setup-android@v3 | |
| with: | |
| packages: platform-tools platforms;android-35 build-tools;35.0.0 | |
| cmdline-tools-version: 12266719 | |
| accept-android-sdk-licenses: true | |
| - name: Flutter pub get | |
| working-directory: ${{ env.FLUTTER_PROJECT }} | |
| run: flutter pub get | |
| - name: Build release APK | |
| working-directory: ${{ env.FLUTTER_PROJECT }} | |
| run: | | |
| set -euxo pipefail | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| flutter build apk --release --build-name "$VERSION" --build-number "${GITHUB_RUN_NUMBER}" | |
| mkdir -p ../dist | |
| cp build/app/outputs/flutter-apk/app-release.apk ../dist/blaz-${GITHUB_REF_NAME}.apk | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-dist | |
| path: dist/*.apk | |
| backend: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: ${{ env.FLUTTER_VERSION }} | |
| cache: true | |
| - name: Cache Flutter pub | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ env.FLUTTER_PROJECT }}/.dart_tool | |
| ${{ env.FLUTTER_PROJECT }}/.pub-cache | |
| ~/.pub-cache | |
| key: ${{ runner.os }}-flutter-pub-${{ hashFiles('flutter/pubspec.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-flutter-pub- | |
| - name: Flutter pub get | |
| working-directory: ${{ env.FLUTTER_PROJECT }} | |
| run: flutter pub get --offline || flutter pub get | |
| - name: Build Flutter web | |
| working-directory: ${{ env.FLUTTER_PROJECT }} | |
| run: flutter build web --release --no-pub | |
| - name: Copy web build to backend | |
| run: | | |
| mkdir -p backend/web_build | |
| cp -r flutter/build/web/* backend/web_build/ | |
| - uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_TOOLCHAIN }} | |
| - uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| ${{ env.RUST_BACKEND_DIR }}/target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('backend/Cargo.lock') }} | |
| - name: Run tests | |
| working-directory: ${{ env.RUST_BACKEND_DIR }} | |
| run: cargo test --locked | |
| - name: Build release binary | |
| working-directory: ${{ env.RUST_BACKEND_DIR }} | |
| run: cargo build --release --locked | |
| - name: Package backend | |
| run: | | |
| set -euxo pipefail | |
| mkdir -p dist | |
| cp backend/target/release/blaz dist/blaz-${GITHUB_REF_NAME}-x86_64-linux | |
| strip dist/blaz-${GITHUB_REF_NAME}-x86_64-linux || true | |
| tar -czf dist/blaz-${GITHUB_REF_NAME}-x86_64-linux.tar.gz -C dist blaz-${GITHUB_REF_NAME}-x86_64-linux | |
| sha256sum dist/* > dist/SHA256SUMS.txt | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: backend-dist | |
| path: dist/* | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [android, backend] | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Flatten artifacts | |
| run: | | |
| set -euxo pipefail | |
| mkdir -p dist | |
| find artifacts -type f -maxdepth 2 -print -exec cp {} dist/ \; | |
| - name: Create/Update GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: Blaz ${{ github.ref_name }} | |
| generate_release_notes: true | |
| files: dist/* | |
| fail_on_unmatched_files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| update-flake: | |
| runs-on: ubuntu-latest | |
| needs: [release] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Compute nix SRI hash and update flake.nix | |
| run: | | |
| set -euo pipefail | |
| TAG="${GITHUB_REF_NAME}" | |
| VERSION="${TAG#v}" | |
| BINARY="blaz-${TAG}-x86_64-linux" | |
| URL="https://github.com/MathieuMoalic/blaz/releases/download/${TAG}/${BINARY}" | |
| curl -fsSL "$URL" -o /tmp/blaz-bin | |
| HEX=$(sha256sum /tmp/blaz-bin | awk '{print $1}') | |
| B64=$(python3 -c "import binascii,base64,sys; print(base64.b64encode(binascii.unhexlify(sys.argv[1])).decode())" "$HEX") | |
| SRI="sha256-${B64}" | |
| OLD_VERSION=$(grep -oP '(?<=version = ")[0-9]+\.[0-9]+\.[0-9]+' flake.nix | tail -1) | |
| sed -i "s|version = \"${OLD_VERSION}\";|version = \"${VERSION}\";|g" flake.nix | |
| sed -i "s|sha256 = \"sha256-[^\"]*\";|sha256 = \"${SRI}\";|" flake.nix | |
| echo "Updated flake.nix: version=${VERSION} hash=${SRI}" | |
| - name: Commit flake.nix update | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add flake.nix | |
| git diff --cached --quiet && echo "No changes" && exit 0 | |
| git commit -m "Update prebuilt to ${GITHUB_REF_NAME}" | |
| git push | |