Update build-and-release-snapshots.yml #4
This file contains 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 and Release Flutter Application | |
on: [push, pull_request] | |
jobs: | |
build-and-release: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: windows-latest | |
artifact-name: "Windows-Snapshot" | |
build-command: "flutter build windows" | |
- os: ubuntu-latest | |
artifact-name: "Linux-Snapshot" | |
build-command: "flutter build linux" | |
- os: macos-latest | |
artifact-name: "macOS-Snapshot" | |
build-command: "flutter build macos" | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build | |
- name: Set up Flutter (Linux and Windows) | |
if: matrix.os != 'macos-latest' | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
cache: true | |
- name: Manually Install Flutter (macOS) | |
if: matrix.os == 'macos-latest' | |
run: | | |
git clone https://github.com/flutter/flutter.git -b stable --depth 1 $HOME/flutter | |
echo "$HOME/flutter/bin" >> $GITHUB_PATH | |
export PATH="$HOME/flutter/bin:$PATH" | |
flutter doctor | |
- name: Build | |
run: ${{ matrix.build-command }} | |
- name: Zip artifacts | |
run: | | |
zip -r ${{ matrix.artifact-name }}.zip ./path/to/build/output | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: snapshot-${{ github.run_number }} | |
release_name: Snapshot Release ${{ github.run_number }} | |
draft: false | |
prerelease: true | |
- name: Upload Artifact to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./${{ matrix.artifact-name }}.zip | |
asset_name: ${{ matrix.artifact-name }}.zip | |
asset_content_type: application/zip |